From d07cf7faaf793dd889dfbed46d6fd74cef11ea3b Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 30 Sep 2014 16:04:20 -0700 Subject: [PATCH] JCLOUDS-692 Remove the CloudSigma v1 provider. --- allcompute/pom.xml | 15 - apis/cloudsigma/README.txt | 6 - apis/cloudsigma/pom.xml | 116 ---- .../org/jclouds/cloudsigma/CloudSigmaApi.java | 448 ------------ .../cloudsigma/CloudSigmaApiMetadata.java | 90 --- ...indCloneDriveOptionsToPlainTextString.java | 91 --- .../BindDriveDataToPlainTextString.java | 59 -- .../binders/BindDriveToPlainTextString.java | 59 -- .../binders/BindServerToPlainTextString.java | 59 -- .../CloudSigmaComputeServiceAdapter.java | 252 ------- .../CloudSigmaTemplateBuilderImpl.java | 47 -- ...CloudSigmaComputeServiceContextModule.java | 124 ---- ...arseOsFamilyVersion64BitFromImageName.java | 85 --- .../functions/PreinstalledDiskToImage.java | 65 -- .../functions/ServerInfoToNodeMetadata.java | 178 ----- .../options/CloudSigmaTemplateOptions.java | 323 --------- .../config/CloudSigmaRestClientModule.java | 90 --- .../cloudsigma/domain/AffinityType.java | 49 -- .../cloudsigma/domain/BlockDevice.java | 83 --- .../jclouds/cloudsigma/domain/ClaimType.java | 54 -- .../cloudsigma/domain/CreateDriveRequest.java | 168 ----- .../org/jclouds/cloudsigma/domain/Device.java | 105 --- .../org/jclouds/cloudsigma/domain/Drive.java | 213 ------ .../jclouds/cloudsigma/domain/DriveData.java | 85 --- .../jclouds/cloudsigma/domain/DriveInfo.java | 470 ------------- .../cloudsigma/domain/DriveMetrics.java | 136 ---- .../cloudsigma/domain/DriveStatus.java | 45 -- .../jclouds/cloudsigma/domain/DriveType.java | 45 -- .../jclouds/cloudsigma/domain/IDEDevice.java | 95 --- .../org/jclouds/cloudsigma/domain/Item.java | 167 ----- .../jclouds/cloudsigma/domain/MediaType.java | 47 -- .../org/jclouds/cloudsigma/domain/Model.java | 44 -- .../org/jclouds/cloudsigma/domain/NIC.java | 174 ----- .../cloudsigma/domain/ProfileInfo.java | 195 ------ .../cloudsigma/domain/ProfileType.java | 44 -- .../jclouds/cloudsigma/domain/SCSIDevice.java | 89 --- .../org/jclouds/cloudsigma/domain/Server.java | 290 -------- .../jclouds/cloudsigma/domain/ServerInfo.java | 255 ------- .../cloudsigma/domain/ServerMetrics.java | 153 ----- .../cloudsigma/domain/ServerStatus.java | 44 -- .../cloudsigma/domain/StaticIPInfo.java | 228 ------- .../jclouds/cloudsigma/domain/VLANInfo.java | 163 ----- .../org/jclouds/cloudsigma/domain/VNC.java | 102 --- .../cloudsigma/functions/BaseDriveToMap.java | 54 -- .../cloudsigma/functions/DriveDataToMap.java | 81 --- ...aluesDelimitedByBlankLinesToDriveInfo.java | 50 -- ...uesDelimitedByBlankLinesToProfileInfo.java | 50 -- ...luesDelimitedByBlankLinesToServerInfo.java | 50 -- ...esDelimitedByBlankLinesToStaticIPInfo.java | 50 -- ...ValuesDelimitedByBlankLinesToVLANInfo.java | 50 -- ...esDelimitedByBlankLinesToDriveInfoSet.java | 57 -- ...luesDelimitedByBlankLinesToListOfMaps.java | 58 -- ...DelimitedByBlankLinesToProfileInfoSet.java | 57 -- ...sDelimitedByBlankLinesToServerInfoSet.java | 58 -- ...elimitedByBlankLinesToStaticIPInfoSet.java | 57 -- ...uesDelimitedByBlankLinesToVLANInfoSet.java | 57 -- ...oListOfKeyValuesDelimitedByBlankLines.java | 55 -- .../cloudsigma/functions/MapToDevices.java | 99 --- .../cloudsigma/functions/MapToDriveInfo.java | 114 ---- .../functions/MapToDriveMetrics.java | 84 --- .../cloudsigma/functions/MapToNICs.java | 56 -- .../functions/MapToProfileInfo.java | 60 -- .../cloudsigma/functions/MapToServerInfo.java | 91 --- .../functions/MapToServerMetrics.java | 57 -- .../functions/MapToStaticIPInfo.java | 60 -- .../cloudsigma/functions/MapToVLANInfo.java | 56 -- .../cloudsigma/functions/ReturnPayload.java | 35 - .../cloudsigma/functions/ServerToMap.java | 78 --- .../cloudsigma/functions/SplitNewlines.java | 49 -- .../SplitNewlinesAndReturnSecondField.java | 64 -- .../handlers/CloudSigmaErrorHandler.java | 105 --- .../cloudsigma/options/CloneDriveOptions.java | 139 ---- .../cloudsigma/predicates/DriveClaimed.java | 60 -- .../reference/CloudSigmaConstants.java | 30 - .../org/jclouds/cloudsigma/util/Servers.java | 83 --- .../services/org.jclouds.apis.ApiMetadata | 1 - .../cloudsigma/CloudSigmaApiMetadataTest.java | 32 - .../jclouds/cloudsigma/CloudSigmaApiTest.java | 646 ------------------ .../cloudsigma/CloudSigmaClientLiveTest.java | 443 ------------ ...loneDriveOptionsToPlainTextStringTest.java | 71 -- .../BindDriveDataToPlainTextStringTest.java | 84 --- .../BindDriveToPlainTextStringTest.java | 87 --- .../BindServerToPlainTextStringTest.java | 89 --- .../CloudSigmaComputeServiceLiveTest.java | 67 -- .../functions/BaseDriveToMapTest.java | 64 -- .../functions/DriveDataToMapTest.java | 78 --- ...sDelimitedByBlankLinesToDriveInfoTest.java | 46 -- ...elimitedByBlankLinesToProfileInfoTest.java | 46 -- ...DelimitedByBlankLinesToServerInfoTest.java | 77 --- ...esDelimitedByBlankLinesToVLANInfoTest.java | 46 -- ...limitedByBlankLinesToDriveInfoSetTest.java | 48 -- ...DelimitedByBlankLinesToListOfMapsTest.java | 63 -- ...imitedByBlankLinesToServerInfoSetTest.java | 77 --- ...elimitedByBlankLinesToVLANInfoSetTest.java | 48 -- ...tOfKeyValuesDelimitedByBlankLinesTest.java | 57 -- .../functions/MapToDriveInfoTest.java | 94 --- .../functions/MapToProfileInfoTest.java | 55 -- .../functions/MapToServerInfoTest.java | 159 ----- .../functions/MapToVLANInfoTest.java | 53 -- ...OsFamilyVersion64BitFromImageNameTest.java | 78 --- .../cloudsigma/functions/ServerToMapTest.java | 63 -- .../functions/SplitNewlinesTest.java | 50 -- .../handlers/CloudSigmaErrorHandlerTest.java | 135 ---- .../options/CloneDriveOptionsTest.java | 129 ---- .../src/test/resources/create_drive.txt | 5 - .../src/test/resources/create_server.txt | 11 - apis/cloudsigma/src/test/resources/drive.txt | 27 - .../src/test/resources/drive_data.txt | 6 - apis/cloudsigma/src/test/resources/log4j.xml | 151 ---- .../src/test/resources/new_server.txt | 24 - .../src/test/resources/osmatches.json | 174 ----- .../cloudsigma/src/test/resources/profile.txt | 28 - .../cloudsigma/src/test/resources/servers.txt | 40 -- apis/cloudsigma/src/test/resources/uuids.txt | 3 - apis/cloudsigma/src/test/resources/vlan.txt | 4 - apis/pom.xml | 1 - providers/cloudsigma-lvs/pom.xml | 125 ---- .../CloudSigmaLasVegasProviderMetadata.java | 83 --- .../org.jclouds.providers.ProviderMetadata | 1 - ...loudSigmaLasVegasLondonClientLiveTest.java | 30 - .../CloudSigmaLasVegasProviderTest.java | 32 - ...udSigmaLasVegasComputeServiceLiveTest.java | 32 - ...dSigmaLasVegasTemplateBuilderLiveTest.java | 89 --- providers/cloudsigma-zrh/pom.xml | 126 ---- .../CloudSigmaZurichProviderMetadata.java | 83 --- .../org.jclouds.providers.ProviderMetadata | 1 - .../CloudSigmaZurichClientLiveTest.java | 30 - .../CloudSigmaZurichProviderTest.java | 32 - ...loudSigmaZurichComputeServiceLiveTest.java | 79 --- ...oudSigmaZurichTemplateBuilderLiveTest.java | 86 --- providers/pom.xml | 2 - 131 files changed, 12045 deletions(-) delete mode 100644 apis/cloudsigma/README.txt delete mode 100644 apis/cloudsigma/pom.xml delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApi.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextString.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindDriveDataToPlainTextString.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindDriveToPlainTextString.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindServerToPlainTextString.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaTemplateBuilderImpl.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ParseOsFamilyVersion64BitFromImageName.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/PreinstalledDiskToImage.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/options/CloudSigmaTemplateOptions.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/AffinityType.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/BlockDevice.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ClaimType.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Device.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveMetrics.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveStatus.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveType.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/IDEDevice.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Item.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/MediaType.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Model.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/NIC.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ProfileInfo.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ProfileType.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/SCSIDevice.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Server.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerInfo.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerMetrics.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerStatus.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/StaticIPInfo.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/VLANInfo.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/VNC.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/BaseDriveToMap.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/DriveDataToMap.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToDriveInfo.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToProfileInfo.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToServerInfo.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToStaticIPInfo.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToVLANInfo.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToListOfMaps.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToProfileInfoSet.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfMapsToListOfKeyValuesDelimitedByBlankLines.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveInfo.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveMetrics.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToNICs.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToProfileInfo.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToServerInfo.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToServerMetrics.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToStaticIPInfo.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToVLANInfo.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ReturnPayload.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ServerToMap.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlines.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlinesAndReturnSecondField.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/handlers/CloudSigmaErrorHandler.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/predicates/DriveClaimed.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/reference/CloudSigmaConstants.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java delete mode 100644 apis/cloudsigma/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextStringTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindDriveDataToPlainTextStringTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindDriveToPlainTextStringTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindServerToPlainTextStringTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/BaseDriveToMapTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/DriveDataToMapTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToDriveInfoTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToProfileInfoTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToServerInfoTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToVLANInfoTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSetTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToListOfMapsTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToServerInfoSetTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSetTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfMapsToListOfKeyValuesDelimitedByBlankLinesTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToDriveInfoTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToProfileInfoTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToServerInfoTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToVLANInfoTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ParseOsFamilyVersion64BitFromImageNameTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ServerToMapTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/SplitNewlinesTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/handlers/CloudSigmaErrorHandlerTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/options/CloneDriveOptionsTest.java delete mode 100644 apis/cloudsigma/src/test/resources/create_drive.txt delete mode 100644 apis/cloudsigma/src/test/resources/create_server.txt delete mode 100644 apis/cloudsigma/src/test/resources/drive.txt delete mode 100644 apis/cloudsigma/src/test/resources/drive_data.txt delete mode 100644 apis/cloudsigma/src/test/resources/log4j.xml delete mode 100644 apis/cloudsigma/src/test/resources/new_server.txt delete mode 100644 apis/cloudsigma/src/test/resources/osmatches.json delete mode 100644 apis/cloudsigma/src/test/resources/profile.txt delete mode 100644 apis/cloudsigma/src/test/resources/servers.txt delete mode 100644 apis/cloudsigma/src/test/resources/uuids.txt delete mode 100644 apis/cloudsigma/src/test/resources/vlan.txt delete mode 100644 providers/cloudsigma-lvs/pom.xml delete mode 100644 providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java delete mode 100644 providers/cloudsigma-lvs/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata delete mode 100644 providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/CloudSigmaLasVegasLondonClientLiveTest.java delete mode 100644 providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderTest.java delete mode 100644 providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasComputeServiceLiveTest.java delete mode 100644 providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java delete mode 100644 providers/cloudsigma-zrh/pom.xml delete mode 100644 providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java delete mode 100644 providers/cloudsigma-zrh/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata delete mode 100644 providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichClientLiveTest.java delete mode 100644 providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderTest.java delete mode 100644 providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichComputeServiceLiveTest.java delete mode 100644 providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java diff --git a/allcompute/pom.xml b/allcompute/pom.xml index 1aa3df26c4..b2be149a1e 100644 --- a/allcompute/pom.xml +++ b/allcompute/pom.xml @@ -78,11 +78,6 @@ vcloud ${project.version} - - org.apache.jclouds.api - cloudsigma - ${project.version} - org.apache.jclouds.provider bluelock-vcloud-zone01 @@ -128,16 +123,6 @@ skalicloud-sdg-my ${project.version} - - org.apache.jclouds.provider - cloudsigma-zrh - ${project.version} - - - org.apache.jclouds.provider - cloudsigma-lvs - ${project.version} - org.apache.jclouds.provider go2cloud-jhb1 diff --git a/apis/cloudsigma/README.txt b/apis/cloudsigma/README.txt deleted file mode 100644 index bddfd04340..0000000000 --- a/apis/cloudsigma/README.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -# The jclouds provider for CloudSigma (http://www.cloudsigma.com/). -# -# TODO: Implementation status. -# TODO: Supported features. -# TODO: Usage example. diff --git a/apis/cloudsigma/pom.xml b/apis/cloudsigma/pom.xml deleted file mode 100644 index 4cd78665b1..0000000000 --- a/apis/cloudsigma/pom.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - 4.0.0 - - org.apache.jclouds - jclouds-project - 1.7.4-SNAPSHOT - ../../project/pom.xml - - org.apache.jclouds.api - cloudsigma - jclouds CloudSigma API - ComputeService binding to the CloudSigma API - bundle - - - https://api.cloudsigma.com - 1.0 - - FIXME - FIXME - imageId=f3c7c665-cd54-4a78-8fd2-7ec2f028cf29 - org.jclouds.cloudsigma*;version="${project.version}" - - org.jclouds.compute.internal;version="${project.version}", - org.jclouds.rest.internal;version="${project.version}", - org.jclouds*;version="${project.version}", - * - - - - - - org.apache.jclouds - jclouds-compute - ${project.version} - - - org.apache.jclouds.driver - jclouds-sshj - ${project.version} - test - - - org.apache.jclouds - jclouds-core - ${project.version} - test-jar - test - - - org.apache.jclouds - jclouds-compute - ${project.version} - test-jar - test - - - org.apache.jclouds.driver - jclouds-log4j - ${project.version} - test - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.cloudsigma.endpoint} - ${test.cloudsigma.api-version} - ${test.cloudsigma.build-version} - ${test.cloudsigma.identity} - ${test.cloudsigma.credential} - ${test.cloudsigma.template} - - - - - - - - - - - diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApi.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApi.java deleted file mode 100644 index 42ffd5ea57..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApi.java +++ /dev/null @@ -1,448 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma; - -import java.io.Closeable; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.cloudsigma.binders.BindCloneDriveOptionsToPlainTextString; -import org.jclouds.cloudsigma.binders.BindDriveDataToPlainTextString; -import org.jclouds.cloudsigma.binders.BindDriveToPlainTextString; -import org.jclouds.cloudsigma.binders.BindServerToPlainTextString; -import org.jclouds.cloudsigma.domain.Drive; -import org.jclouds.cloudsigma.domain.DriveData; -import org.jclouds.cloudsigma.domain.DriveInfo; -import org.jclouds.cloudsigma.domain.ProfileInfo; -import org.jclouds.cloudsigma.domain.Server; -import org.jclouds.cloudsigma.domain.ServerInfo; -import org.jclouds.cloudsigma.domain.StaticIPInfo; -import org.jclouds.cloudsigma.domain.VLANInfo; -import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToDriveInfo; -import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToProfileInfo; -import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToServerInfo; -import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToStaticIPInfo; -import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToVLANInfo; -import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet; -import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet; -import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet; -import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet; -import org.jclouds.cloudsigma.functions.SplitNewlines; -import org.jclouds.cloudsigma.functions.SplitNewlinesAndReturnSecondField; -import org.jclouds.cloudsigma.options.CloneDriveOptions; -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.Payload; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; - -/** - * Provides synchronous access to CloudSigma via their REST API. - *

- * - * @see - * @author Adrian Cole - */ -@RequestFilters(BasicAuthentication.class) -@Consumes(MediaType.TEXT_PLAIN) -public interface CloudSigmaApi extends Closeable { - - /** - * list of drive uuids that are in the library - * - * @return or empty set if no drives are found - */ - @GET - @Path("/drives/standard/list") - @ResponseParser(SplitNewlines.class) - Set listStandardDrives(); - - /** - * list of cd uuids that are in the library - * - * @return or empty set if no cds are found - */ - @GET - @Path("/drives/standard/cd/list") - @ResponseParser(SplitNewlines.class) - Set listStandardCds(); - - /** - * list of image uuids that are in the library - * - * @return or empty set if no images are found - */ - @GET - @Path("/drives/standard/img/list") - @ResponseParser(SplitNewlines.class) - Set listStandardImages(); - - /** - * Clone an existing drive. By default, the size is the same as the source - * - * @param sourceUuid - * source to clone - * @param newName - * name of the resulting drive - * @param options - * options to control size - * @return new drive - */ - @POST - @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class) - @Path("/drives/{uuid}/clone") - @MapBinder(BindCloneDriveOptionsToPlainTextString.class) - DriveInfo cloneDrive(@PathParam("uuid") String sourceUuid, @PayloadParam("name") String newName, - CloneDriveOptions... options); - - /** - * Get profile info - * - * @return info or null, if not found - */ - @GET - @Path("/profile/info") - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(KeyValuesDelimitedByBlankLinesToProfileInfo.class) - ProfileInfo getProfileInfo(); - - /** - * Get all drives info - * - * @return or empty set if no drives are found - */ - @GET - @Path("/drives/info") - @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class) - Set listDriveInfo(); - - /** - * @param uuid - * what to get - * @return null, if not found - */ - @GET - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class) - @Path("/drives/{uuid}/info") - DriveInfo getDriveInfo(@PathParam("uuid") String uuid); - - /** - * create a new drive - * - * @param createDrive - * required parameters: name, size - * @return newly created drive - */ - @POST - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class) - @Path("/drives/create") - DriveInfo createDrive(@BinderParam(BindDriveToPlainTextString.class) Drive createDrive); - - /** - * set extra drive data - * - * @param uuid - * what drive to change - * @param createDrive - * what values to change - * @return new data - */ - @POST - @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class) - @Path("/drives/{uuid}/set") - DriveInfo setDriveData(@PathParam("uuid") String uuid, - @BinderParam(BindDriveDataToPlainTextString.class) DriveData createDrive); - - /** - * create a new server - * - * @param createServer - * @return newly created server - */ - @POST - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class) - @Path("/servers/create") - ServerInfo createServer(@BinderParam(BindServerToPlainTextString.class) Server createServer); - - /** - * Get all servers info - * - * @return or empty set if no servers are found - */ - @GET - @Path("/servers/info") - @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.class) - Set listServerInfo(); - - /** - * @param uuid - * what to get - * @return null, if not found - */ - @GET - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class) - @Path("/servers/{uuid}/info") - ServerInfo getServerInfo(@PathParam("uuid") String uuid); - - /** - * set server configuration - * - * @param uuid - * what server to change - * @param setServer - * what values to change - * @return new data - */ - @POST - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class) - @Path("/servers/{uuid}/set") - ServerInfo setServerConfiguration(@PathParam("uuid") String uuid, - @BinderParam(BindServerToPlainTextString.class) Server setServer); - - /** - * list of server uuids in your account - * - * @return or empty set if no servers are found - */ - @GET - @Path("/servers/list") - @ResponseParser(SplitNewlines.class) - Set listServers(); - - /** - * Destroy a server - * - * @param uuid - * what to destroy - */ - @GET - @Path("/servers/{uuid}/destroy") - @Fallback(VoidOnNotFoundOr404.class) - void destroyServer(@PathParam("uuid") String uuid); - - /** - * Start a server - * - * @param uuid - * what to start - */ - @POST - @Path("/servers/{uuid}/start") - void startServer(@PathParam("uuid") String uuid); - - /** - * Stop a server - *

- * Kills the server immediately, equivalent to a power failure. Server reverts to a stopped - * status if it is persistent and is automatically destroyed otherwise. - * - * @param uuid - * what to stop - */ - @POST - @Path("/servers/{uuid}/stop") - void stopServer(@PathParam("uuid") String uuid); - - /** - * Shutdown a server - *

- * Sends the server an ACPI power-down event. Server reverts to a stopped status if it is - * persistent and is automatically destroyed otherwise. - *

note

behaviour on shutdown depends on how your server OS is set up to respond to an - * ACPI power button signal. - * - * @param uuid - * what to shutdown - */ - @POST - @Path("/servers/{uuid}/shutdown") - void shutdownServer(@PathParam("uuid") String uuid); - - /** - * Reset a server - * - * @param uuid - * what to reset - */ - @POST - @Path("/servers/{uuid}/reset") - void resetServer(@PathParam("uuid") String uuid); - - /** - * list of drive uuids in your account - * - * @return or empty set if no drives are found - */ - @GET - @Path("/drives/list") - @ResponseParser(SplitNewlines.class) - Set listDrives(); - - /** - * Destroy a drive - * - * @param uuid - * what to delete - */ - @GET - @Path("/drives/{uuid}/destroy") - @Fallback(VoidOnNotFoundOr404.class) - void destroyDrive(@PathParam("uuid") String uuid); - - /** - * create a new vlan - * - * @param name - * @return newly created vlan - */ - @POST - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class) - @Path("/resources/vlan/create") - @Payload("name {name}\n") - @Produces(MediaType.TEXT_PLAIN) - VLANInfo createVLAN(@PayloadParam("name") String name); - - /** - * Get all vlans info - * - * @return or empty set if no vlans are found - */ - @GET - @Path("/resources/vlan/info") - @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.class) - Set listVLANInfo(); - - /** - * @param uuid - * what to get - * @return null, if not found - */ - @GET - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class) - @Path("/resources/vlan/{uuid}/info") - VLANInfo getVLANInfo(@PathParam("uuid") String uuid); - - /** - * set vlan configuration - * - * @param uuid - * what vlan to change - * @param name - * what the new name is - * @return new data - */ - @POST - @ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class) - @Path("/resources/vlan/{uuid}/set") - @Payload("name {name}\n") - @Produces(MediaType.TEXT_PLAIN) - VLANInfo renameVLAN(@PathParam("uuid") String uuid, @PayloadParam("name") String name); - - /** - * list of vlan uuids in your account - * - * @return or empty set if no vlans are found - */ - @GET - @Path("/resources/vlan/list") - @ResponseParser(SplitNewlinesAndReturnSecondField.class) - Set listVLANs(); - - /** - * Destroy a vlan - * - * @param uuid - * what to destroy - */ - @GET - @Path("/resources/vlan/{uuid}/destroy") - @Fallback(VoidOnNotFoundOr404.class) - void destroyVLAN(@PathParam("uuid") String uuid); - - /** - * create a new ip - * - * @return newly created ip - */ - @POST - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(KeyValuesDelimitedByBlankLinesToStaticIPInfo.class) - @Path("/resources/ip/create") - StaticIPInfo createStaticIP(); - - /** - * Get all ips info - * - * @return or empty set if no ips are found - */ - @GET - @Path("/resources/ip/info") - @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet.class) - Set listStaticIPInfo(); - - /** - * @param uuid - * what to get - * @return null, if not found - */ - @GET - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(KeyValuesDelimitedByBlankLinesToStaticIPInfo.class) - @Path("/resources/ip/{uuid}/info") - StaticIPInfo getStaticIPInfo(@PathParam("uuid") String uuid); - - /** - * list of ip uuids in your account - * - * @return or empty set if no ips are found - */ - @GET - @Path("/resources/ip/list") - @ResponseParser(SplitNewlinesAndReturnSecondField.class) - Set listStaticIPs(); - - /** - * Destroy a ip - * - * @param uuid - * what to destroy - */ - @GET - @Path("/resources/ip/{uuid}/destroy") - @Fallback(VoidOnNotFoundOr404.class) - void destroyStaticIP(@PathParam("uuid") String uuid); - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java deleted file mode 100644 index f5d31a6fa0..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma; -import static org.jclouds.cloudsigma.reference.CloudSigmaConstants.PROPERTY_VNC_PASSWORD; -import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; -import static org.jclouds.reflect.Reflection2.typeToken; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule; -import org.jclouds.cloudsigma.config.CloudSigmaRestClientModule; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.rest.internal.BaseHttpApiMetadata; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -/** - * Implementation of {@link ApiMetadata} for the Cloud Sigma API - * - * @author Adrian Cole - */ -public class CloudSigmaApiMetadata extends BaseHttpApiMetadata { - - - @Override - public Builder toBuilder() { - return new Builder().fromApiMetadata(this); - } - - public CloudSigmaApiMetadata() { - this(new Builder()); - } - - protected CloudSigmaApiMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = BaseHttpApiMetadata.defaultProperties(); - properties.setProperty(PROPERTY_VNC_PASSWORD, "IL9vs34d"); - // passwords are set post-boot, so auth failures are possible - // from a race condition applying the password set script - properties.setProperty("jclouds.ssh.max-retries", "7"); - properties.setProperty("jclouds.ssh.retry-auth", "true"); - properties.setProperty(TEMPLATE, "osFamily=UBUNTU,imageNameMatches=.*[Aa]utomated SSH Access.*,os64Bit=true"); - return properties; - } - - public static class Builder extends BaseHttpApiMetadata.Builder { - - protected Builder() { - id("cloudsigma") - .name("CloudSigma API") - .identityName("Email") - .credentialName("Password") - .documentation(URI.create("http://cloudsigma.com/en/platform-details/the-api")) - .version("1.0") - .defaultEndpoint("https://api.cloudsigma.com") - .defaultProperties(CloudSigmaApiMetadata.defaultProperties()) - .view(typeToken(ComputeServiceContext.class)) - .defaultModules(ImmutableSet.>of(CloudSigmaRestClientModule.class, CloudSigmaComputeServiceContextModule.class)); - } - - @Override - public CloudSigmaApiMetadata build() { - return new CloudSigmaApiMetadata(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextString.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextString.java deleted file mode 100644 index 8303b3ebfe..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextString.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.ws.rs.core.MediaType; - -import org.jclouds.cloudsigma.functions.ListOfMapsToListOfKeyValuesDelimitedByBlankLines; -import org.jclouds.cloudsigma.options.CloneDriveOptions; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.internal.GeneratedHttpRequest; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class BindCloneDriveOptionsToPlainTextString implements MapBinder { - private final ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines; - - @Inject - public BindCloneDriveOptionsToPlainTextString( - ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines) { - this.listOfMapsToListOfKeyValuesDelimitedByBlankLines = listOfMapsToListOfKeyValuesDelimitedByBlankLines; - } - - @Override - public R bindToRequest(R request, Map postParams) { - checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, - "this binder is only valid for GeneratedHttpRequests!"); - GeneratedHttpRequest gRequest = GeneratedHttpRequest.class.cast(request); - - CloneDriveOptions options = findOptionsInArgsOrNull(gRequest); - if (options != null) { - postParams = ImmutableMap. builder().putAll(postParams).putAll(options.getOptions()).build(); - } - - request.setPayload(listOfMapsToListOfKeyValuesDelimitedByBlankLines.apply(ImmutableSet.of(Maps.transformValues(postParams, new Function() { - @Override - public String apply(Object input) { - return input == null ? null : input.toString(); - } - })))); - request.getPayload().getContentMetadata().setContentType(MediaType.TEXT_PLAIN); - return request; - } - - static CloneDriveOptions findOptionsInArgsOrNull(GeneratedHttpRequest gRequest) { - for (Object arg : gRequest.getInvocation().getArgs()) { - if (arg instanceof CloneDriveOptions) { - return (CloneDriveOptions) arg; - } else if (arg instanceof CloneDriveOptions[]) { - CloneDriveOptions[] options = (CloneDriveOptions[]) arg; - return (options.length > 0) ? options[0] : null; - } - } - return null; - } - - @Override - public R bindToRequest(R request, Object input) { - throw new UnsupportedOperationException(); - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindDriveDataToPlainTextString.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindDriveDataToPlainTextString.java deleted file mode 100644 index a82c9d19a4..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindDriveDataToPlainTextString.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.binders; - -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.ws.rs.core.MediaType; - -import org.jclouds.cloudsigma.domain.DriveData; -import org.jclouds.cloudsigma.functions.ListOfMapsToListOfKeyValuesDelimitedByBlankLines; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class BindDriveDataToPlainTextString implements Binder { - private final Function> createDriveRequestToMap; - private final ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines; - - @Inject - public BindDriveDataToPlainTextString(Function> createDriveRequestToMap, - ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines) { - this.createDriveRequestToMap = createDriveRequestToMap; - this.listOfMapsToListOfKeyValuesDelimitedByBlankLines = listOfMapsToListOfKeyValuesDelimitedByBlankLines; - } - @Override - public R bindToRequest(R request, Object payload) { - checkArgument(payload instanceof DriveData, "this binder is only valid for DriveData!"); - DriveData create = DriveData.class.cast(payload); - Map map = createDriveRequestToMap.apply(create); - request.setPayload(listOfMapsToListOfKeyValuesDelimitedByBlankLines.apply(ImmutableSet.of(map))); - request.getPayload().getContentMetadata().setContentType(MediaType.TEXT_PLAIN); - return request; - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindDriveToPlainTextString.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindDriveToPlainTextString.java deleted file mode 100644 index 77794c1d91..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindDriveToPlainTextString.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.binders; - -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.ws.rs.core.MediaType; - -import org.jclouds.cloudsigma.domain.Drive; -import org.jclouds.cloudsigma.functions.ListOfMapsToListOfKeyValuesDelimitedByBlankLines; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class BindDriveToPlainTextString implements Binder { - private final Function> createDriveRequestToMap; - private final ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines; - - @Inject - public BindDriveToPlainTextString(Function> createDriveRequestToMap, - ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines) { - this.createDriveRequestToMap = createDriveRequestToMap; - this.listOfMapsToListOfKeyValuesDelimitedByBlankLines = listOfMapsToListOfKeyValuesDelimitedByBlankLines; - } - @Override - public R bindToRequest(R request, Object payload) { - checkArgument(payload instanceof Drive, "this binder is only valid for Drive!"); - Drive create = Drive.class.cast(payload); - Map map = createDriveRequestToMap.apply(create); - request.setPayload(listOfMapsToListOfKeyValuesDelimitedByBlankLines.apply(ImmutableSet.of(map))); - request.getPayload().getContentMetadata().setContentType(MediaType.TEXT_PLAIN); - return request; - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindServerToPlainTextString.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindServerToPlainTextString.java deleted file mode 100644 index 3454be0299..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindServerToPlainTextString.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.binders; - -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.ws.rs.core.MediaType; - -import org.jclouds.cloudsigma.domain.Server; -import org.jclouds.cloudsigma.functions.ListOfMapsToListOfKeyValuesDelimitedByBlankLines; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class BindServerToPlainTextString implements Binder { - private final Function> createServerRequestToMap; - private final ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines; - - @Inject - public BindServerToPlainTextString(Function> createServerRequestToMap, - ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines) { - this.createServerRequestToMap = createServerRequestToMap; - this.listOfMapsToListOfKeyValuesDelimitedByBlankLines = listOfMapsToListOfKeyValuesDelimitedByBlankLines; - } - @Override - public R bindToRequest(R request, Object payload) { - checkArgument(payload instanceof Server, "this binder is only valid for Server!"); - Server create = Server.class.cast(payload); - Map map = createServerRequestToMap.apply(create); - request.setPayload(listOfMapsToListOfKeyValuesDelimitedByBlankLines.apply(ImmutableSet.of(map))); - request.getPayload().getContentMetadata().setContentType(MediaType.TEXT_PLAIN); - return request; - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java deleted file mode 100644 index cfcffc1789..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.compute; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.contains; -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.concurrent.FutureIterables.transformParallel; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.Constants; -import org.jclouds.cloudsigma.CloudSigmaApi; -import org.jclouds.cloudsigma.compute.options.CloudSigmaTemplateOptions; -import org.jclouds.cloudsigma.domain.AffinityType; -import org.jclouds.cloudsigma.domain.Device; -import org.jclouds.cloudsigma.domain.DriveInfo; -import org.jclouds.cloudsigma.domain.DriveType; -import org.jclouds.cloudsigma.domain.Server; -import org.jclouds.cloudsigma.domain.ServerInfo; -import org.jclouds.cloudsigma.options.CloneDriveOptions; -import org.jclouds.cloudsigma.reference.CloudSigmaConstants; -import org.jclouds.cloudsigma.util.Servers; -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.HardwareBuilder; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.Processor; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.Volume; -import org.jclouds.compute.domain.internal.VolumeImpl; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.domain.Location; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.logging.Logger; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.UncheckedExecutionException; - -/** - * defines the connection between the {@link org.jclouds.cloudsigma.CloudSigmaApi} implementation - * and the jclouds {@link ComputeService} - * - */ -@Singleton -public class CloudSigmaComputeServiceAdapter implements - ComputeServiceAdapter { - private static final Predicate PREINSTALLED_DISK = Predicates.and(Predicates.notNull(), - new Predicate() { - - @Override - public boolean apply(DriveInfo drive) { - return drive.getType().equals(DriveType.DISK) && drive.getDriveType().contains("preinstalled"); - } - - }); - private final CloudSigmaApi client; - private final Predicate driveNotClaimed; - private final String defaultVncPassword; - private final LoadingCache cache; - private final ListeningExecutorService userExecutor; - - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; - - @Inject - public CloudSigmaComputeServiceAdapter(CloudSigmaApi client, Predicate driveNotClaimed, - @Named(CloudSigmaConstants.PROPERTY_VNC_PASSWORD) String defaultVncPassword, - LoadingCache cache, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) { - this.client = checkNotNull(client, "client"); - this.driveNotClaimed = checkNotNull(driveNotClaimed, "driveNotClaimed"); - this.defaultVncPassword = checkNotNull(defaultVncPassword, "defaultVncPassword"); - checkArgument(defaultVncPassword.length() <= 8, "vnc passwords should be less that 8 characters!"); - this.cache = checkNotNull(cache, "cache"); - this.userExecutor = checkNotNull(userExecutor, "userExecutor"); - } - - @Override - public NodeAndInitialCredentials createNodeWithGroupEncodedIntoName(String tag, String name, Template template) { - long bootSize = (long) (template.getHardware().getVolumes().get(0).getSize() * 1024 * 1024 * 1024l); - AffinityType affinityType = AffinityType.HDD; - if (template.getOptions() instanceof CloudSigmaTemplateOptions) { - CloudSigmaTemplateOptions options = CloudSigmaTemplateOptions.class.cast(template.getOptions()); - affinityType = options.getDiskDriveAffinity(); - } - logger.debug(">> imaging boot drive source(%s) bytes(%d) affinityType(%s)", - template.getImage().getId(), bootSize, affinityType); - DriveInfo drive = client.cloneDrive(template.getImage().getId(), template.getImage().getId(), - new CloneDriveOptions().size(bootSize).affinity(affinityType)); - boolean success = driveNotClaimed.apply(drive); - logger.debug("<< image(%s) complete(%s)", drive.getUuid(), success); - if (!success) { - client.destroyDrive(drive.getUuid()); - throw new IllegalStateException("could not image drive in time!"); - } - - Server toCreate = Servers.small(name, drive.getUuid(), defaultVncPassword).mem(template.getHardware().getRam()) - .cpu((int) (template.getHardware().getProcessors().get(0).getSpeed())).build(); - - logger.debug(">> creating server"); - ServerInfo from = client.createServer(toCreate); - logger.debug("<< created server(%s)", from.getUuid()); - logger.debug(">> starting server(%s)", from.getUuid()); - client.startServer(from.getUuid()); - return new NodeAndInitialCredentials(from, from.getUuid(), LoginCredentials.builder() - .password(defaultVncPassword).authenticateSudo(true).build()); - } - - @Override - public Iterable listHardwareProfiles() { - Builder hardware = ImmutableSet.builder(); - for (double cpu : new double[] { 1000, 5000, 10000, 20000 }) - for (int ram : new int[] { 512, 1024, 4 * 1024, 16 * 1024, 32 * 1024 }) { - final float size = (float) cpu / 100; - String id = String.format("cpu=%f,ram=%s,disk=%f", cpu, ram, size); - hardware.add(new HardwareBuilder().supportsImage(new Predicate() { - - @Override - public boolean apply(Image input) { - String toParse = input.getUserMetadata().get("size"); - return toParse != null && new Float(toParse) <= size; - } - - @Override - public String toString() { - return "sizeLessThanOrEqual(" + size + ")"; - } - - }).ids(id).ram(ram).processors(ImmutableList.of(new Processor(1, cpu))).hypervisor("kvm") - .volumes(ImmutableList.of(new VolumeImpl(size, true, true))).build()); - } - return hardware.build(); - } - - /** - * look up the current standard images and do not error out, if they are not - * found. - */ - @Override - public Iterable listImages() { - return FluentIterable.from(transformParallel(client.listStandardDrives(), - new Function>() { - - @Override - public ListenableFuture apply(String input) { - try { - return Futures.immediateFuture(cache.getUnchecked(input)); - } catch (CacheLoader.InvalidCacheLoadException e) { - logger.debug("drive %s not found", input); - } catch (UncheckedExecutionException e) { - logger.warn(e, "error finding drive %s: %s", input, e.getMessage()); - } - return Futures.immediateFuture(null); - } - - @Override - public String toString() { - return "seedDriveCache()"; - } - }, userExecutor, null, logger, "drives")).filter(PREINSTALLED_DISK); - } - - @SuppressWarnings("unchecked") - @Override - public Iterable listNodes() { - return (Iterable) client.listServerInfo(); - } - - @Override - public Iterable listNodesByIds(final Iterable ids) { - return filter(listNodes(), new Predicate() { - - @Override - public boolean apply(ServerInfo server) { - return contains(ids, server.getUuid()); - } - }); - } - - @Override - public Iterable listLocations() { - // Not using the adapter to determine locations - return ImmutableSet.of(); - } - - @Override - public ServerInfo getNode(String id) { - return client.getServerInfo(id); - } - - @Override - public DriveInfo getImage(String id) { - return client.getDriveInfo(id); - } - - @Override - public void destroyNode(String id) { - ServerInfo server = getNode(id); - if (server != null) { - client.stopServer(id); - client.destroyServer(id); - for (Device dev : server.getDevices().values()) - client.destroyDrive(dev.getDriveUuid()); - } - } - - @Override - public void rebootNode(String id) { - client.resetServer(id); - } - - @Override - public void resumeNode(String id) { - client.startServer(id); - - } - - @Override - public void suspendNode(String id) { - client.stopServer(id); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaTemplateBuilderImpl.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaTemplateBuilderImpl.java deleted file mode 100644 index 2032db9b23..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaTemplateBuilderImpl.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.compute; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Provider; - -import org.jclouds.collect.Memoized; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.TemplateBuilder; -import org.jclouds.compute.domain.internal.TemplateBuilderImpl; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.compute.strategy.GetImageStrategy; -import org.jclouds.compute.suppliers.ImageCacheSupplier; -import org.jclouds.domain.Location; - -import com.google.common.base.Supplier; - -/** - * @author Andrei Savu - */ -public class CloudSigmaTemplateBuilderImpl extends TemplateBuilderImpl { - @Inject - public CloudSigmaTemplateBuilderImpl(@Memoized Supplier> locations, - ImageCacheSupplier images, @Memoized Supplier> hardwares, - Supplier defaultLocation2, @Named("DEFAULT") Provider optionsProvider, - @Named("DEFAULT") Provider defaultTemplateProvider, GetImageStrategy getImageStrategy) { - super(locations, images, hardwares, defaultLocation2, optionsProvider, defaultTemplateProvider, getImageStrategy); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java deleted file mode 100644 index d9ddeacd09..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.compute.config; - -import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static org.jclouds.util.Predicates2.retry; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.CloudSigmaApi; -import org.jclouds.cloudsigma.compute.CloudSigmaComputeServiceAdapter; -import org.jclouds.cloudsigma.compute.CloudSigmaTemplateBuilderImpl; -import org.jclouds.cloudsigma.compute.functions.ParseOsFamilyVersion64BitFromImageName; -import org.jclouds.cloudsigma.compute.functions.PreinstalledDiskToImage; -import org.jclouds.cloudsigma.compute.functions.ServerInfoToNodeMetadata; -import org.jclouds.cloudsigma.compute.functions.ServerInfoToNodeMetadata.DeviceToVolume; -import org.jclouds.cloudsigma.compute.functions.ServerInfoToNodeMetadata.GetImageIdFromServer; -import org.jclouds.cloudsigma.compute.options.CloudSigmaTemplateOptions; -import org.jclouds.cloudsigma.domain.Device; -import org.jclouds.cloudsigma.domain.DriveInfo; -import org.jclouds.cloudsigma.domain.Server; -import org.jclouds.cloudsigma.domain.ServerInfo; -import org.jclouds.cloudsigma.predicates.DriveClaimed; -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.config.ComputeServiceAdapterContextModule; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.OsFamilyVersion64Bit; -import org.jclouds.compute.domain.TemplateBuilder; -import org.jclouds.compute.domain.Volume; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts; -import org.jclouds.domain.Location; -import org.jclouds.functions.IdentityFunction; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.inject.Provides; -import com.google.inject.TypeLiteral; - -/** - * - * @author Adrian Cole - */ -public class CloudSigmaComputeServiceContextModule extends - ComputeServiceAdapterContextModule { - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - protected void configure() { - super.configure(); - bind(new TypeLiteral>() { - }).to(CloudSigmaComputeServiceAdapter.class); - bind(new TypeLiteral>() { - }).to(ServerInfoToNodeMetadata.class); - bind(new TypeLiteral>() { - }).to(Class.class.cast(IdentityFunction.class)); - bind(new TypeLiteral>() { - }).to(PreinstalledDiskToImage.class); - bind(new TypeLiteral>() { - }).to(Class.class.cast(IdentityFunction.class)); - bind(new TypeLiteral>() { - }).to(DeviceToVolume.class); - bind(new TypeLiteral>() { - }).to(GetImageIdFromServer.class); - bind(new TypeLiteral>() { - }).to(ParseOsFamilyVersion64BitFromImageName.class); - bind(TemplateBuilder.class) - .to(CloudSigmaTemplateBuilderImpl.class); - } - - @Provides - @Singleton - protected LoadingCache cache(GetDrive getDrive) { - return CacheBuilder.newBuilder().build(getDrive); - } - - @Singleton - public static class GetDrive extends CacheLoader { - private final CloudSigmaApi client; - - @Inject - public GetDrive(CloudSigmaApi client) { - this.client = client; - } - - @Override - public DriveInfo load(String input) { - return client.getDriveInfo(input); - } - } - - @Provides - @Singleton - protected Predicate supplyDriveUnclaimed(DriveClaimed driveClaimed, Timeouts timeouts) { - return retry(Predicates.not(driveClaimed), timeouts.nodeRunning, 1000, MILLISECONDS); - } - - @Provides - @Singleton - protected TemplateOptions templateOptions() { - return new CloudSigmaTemplateOptions(); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ParseOsFamilyVersion64BitFromImageName.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ParseOsFamilyVersion64BitFromImageName.java deleted file mode 100644 index 4452ce52ae..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ParseOsFamilyVersion64BitFromImageName.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.compute.functions; - -import static com.google.common.base.Predicates.and; -import static com.google.common.base.Predicates.containsPattern; -import static com.google.common.base.Predicates.not; -import static com.google.common.base.Predicates.or; - -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.OsFamilyVersion64Bit; -import org.jclouds.compute.util.ComputeServiceUtils; - -import com.google.common.base.Function; - -/** - * Defaults to version null and 64bit, if the operating system is unrecognized and the pattern - * "32bit" isn't in the string. - * - * @author Adrian Cole - * - */ -@Singleton -public class ParseOsFamilyVersion64BitFromImageName implements Function { - private final Map> osVersionMap; - - @Inject - public ParseOsFamilyVersion64BitFromImageName(Map> osVersionMap) { - this.osVersionMap = osVersionMap; - } - - // ex CentOS 5.5 Linux 64bit Preinstalled System with AppFirst Monitoring - // ex. Centos-5.6-20110917 pub - public static final Pattern PATTERN = Pattern.compile("([^ -]+)[^0-9]([0-9.]+)[ -].*"); - - @Override - public OsFamilyVersion64Bit apply(String input) { - boolean is64Bit = and(not(containsPattern("32bit")), - or(containsPattern("64bit"), not(containsPattern("Windows")))).apply(input); - if (input.contains("Windows")) { - String version = null; - Matcher matcher = Pattern.compile(".*(20[01][0-9] R[1-9]).*").matcher(input); - if (matcher.find()) { - version = matcher.group(1); - } else { - matcher = Pattern.compile(".*(20[01][0-9]).*").matcher(input); - if (matcher.find()) - version = matcher.group(1); - } - return new OsFamilyVersion64Bit(OsFamily.WINDOWS, osVersionMap.get(OsFamily.WINDOWS).get(version), is64Bit); - } else { - Matcher matcher = PATTERN.matcher(input); - if (matcher.find()) { - OsFamily fam = OsFamily.fromValue(matcher.group(1).toLowerCase()); - if (fam == OsFamily.UNRECOGNIZED) - return new OsFamilyVersion64Bit(OsFamily.UNRECOGNIZED, null, is64Bit); - return new OsFamilyVersion64Bit(fam, ComputeServiceUtils.parseVersionOrReturnEmptyString(fam, matcher - .group(2), osVersionMap), is64Bit); - } else { - return new OsFamilyVersion64Bit(OsFamily.UNRECOGNIZED, null, is64Bit); - } - } - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/PreinstalledDiskToImage.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/PreinstalledDiskToImage.java deleted file mode 100644 index 5b9a3681f1..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/PreinstalledDiskToImage.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.compute.functions; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.DriveInfo; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.Image.Status; -import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OperatingSystem.Builder; -import org.jclouds.compute.domain.OsFamilyVersion64Bit; -import org.jclouds.domain.Location; - -import com.google.common.base.Function; -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMap; - -/** - * @author Adrian Cole - */ -@Singleton -public class PreinstalledDiskToImage implements Function { - private final Supplier locationSupplier; - private final Function imageParser; - - @Inject - public PreinstalledDiskToImage(Supplier locationSupplier, - Function imageParser) { - this.locationSupplier = locationSupplier; - this.imageParser = imageParser; - } - - @Override - public Image apply(DriveInfo drive) { - if (drive.getName() == null) - return null; - String description = drive.getDescription() != null ? drive.getDescription() : drive.getName(); - Builder builder = OperatingSystem.builder(); - OsFamilyVersion64Bit parsed = imageParser.apply(drive.getName()); - builder.name(drive.getName()).description(description) - .is64Bit(drive.getBits() != null ? drive.getBits() == 64 : parsed.is64Bit).version(parsed.version) - .family(parsed.family); - return new ImageBuilder().ids(drive.getUuid()) - .userMetadata(ImmutableMap. of("size", drive.getSize() / 1024 / 1024 / 1024 + "")) - .location(locationSupplier.get()).name(drive.getName()).description(description) - .operatingSystem(builder.build()).status(Status.AVAILABLE).version("").build(); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java deleted file mode 100644 index 0d113c625c..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.compute.functions; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.predicates.ImagePredicates.idEquals; - -import java.util.Map; -import java.util.Set; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.Device; -import org.jclouds.cloudsigma.domain.DriveInfo; -import org.jclouds.cloudsigma.domain.Server; -import org.jclouds.cloudsigma.domain.ServerInfo; -import org.jclouds.cloudsigma.domain.ServerStatus; -import org.jclouds.collect.Memoized; -import org.jclouds.compute.domain.HardwareBuilder; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.NodeMetadata.Status; -import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.Processor; -import org.jclouds.compute.domain.Volume; -import org.jclouds.compute.domain.VolumeBuilder; -import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.domain.Location; -import org.jclouds.logging.Logger; - -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.base.Supplier; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.util.concurrent.UncheckedExecutionException; - -/** - * @author Adrian Cole - */ -@Singleton -public class ServerInfoToNodeMetadata implements Function { - public static final Map serverStatusToNodeStatus = ImmutableMap - . builder().put(ServerStatus.ACTIVE, Status.RUNNING)// - .put(ServerStatus.STOPPED, Status.SUSPENDED)// - .put(ServerStatus.PAUSED, Status.SUSPENDED)// - .put(ServerStatus.DUMPED, Status.PENDING)// - .put(ServerStatus.DEAD, Status.TERMINATED)// - .put(ServerStatus.UNRECOGNIZED, Status.UNRECOGNIZED)// - .build(); - - private final Function getImageIdFromServer; - private final Supplier> images; - private final Supplier locationSupplier; - private final Function deviceToVolume; - private final GroupNamingConvention nodeNamingConvention; - - @Inject - ServerInfoToNodeMetadata(Function getImageIdFromServer, @Memoized Supplier> images, - Function deviceToVolume, Supplier locationSupplier, - GroupNamingConvention.Factory namingConvention) { - this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix(); - this.locationSupplier = checkNotNull(locationSupplier, "locationSupplier"); - this.deviceToVolume = checkNotNull(deviceToVolume, "deviceToVolume"); - this.images = checkNotNull(images, "images"); - this.getImageIdFromServer = checkNotNull(getImageIdFromServer, "getImageIdFromServer"); - } - - @Override - public NodeMetadata apply(ServerInfo from) { - NodeMetadataBuilder builder = new NodeMetadataBuilder(); - builder.ids(from.getUuid()); - builder.name(from.getName()); - builder.location(locationSupplier.get()); - builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName())); - - String imageId = getImageIdFromServer.apply(from); - if (imageId != null) { - Optional image = FluentIterable.from(images.get()).firstMatch(idEquals(imageId)); - if (image.isPresent()) { - builder.operatingSystem(image.get().getOperatingSystem()); - } - } - builder.hardware(new HardwareBuilder().ids(from.getUuid()).hypervisor("kvm") - .processors(ImmutableList.of(new Processor(1, from.getCpu()))).ram(from.getMem()) - .volumes(Iterables.transform(from.getDevices().values(), deviceToVolume)).build()); - builder.status(serverStatusToNodeStatus.get(from.getStatus())); - builder.publicAddresses(ImmutableSet. of(from.getVnc().getIp())); - builder.privateAddresses(ImmutableSet. of()); - return builder.build(); - } - - @Singleton - public static final class DeviceToVolume implements Function { - @Resource - protected Logger logger = Logger.NULL; - - private final LoadingCache cache; - - @Inject - public DeviceToVolume(LoadingCache cache) { - this.cache = checkNotNull(cache, "cache"); - } - - @Override - public Volume apply(Device input) { - VolumeBuilder builder = new VolumeBuilder(); - builder.id(input.getId()); - try { - DriveInfo drive = cache.getUnchecked(input.getDriveUuid()); - builder.size((float) drive.getSize()); - } catch (NullPointerException e) { - logger.debug("drive %s not found", input.getDriveUuid()); - } catch (UncheckedExecutionException e) { - logger.warn(e, "error finding drive %s: %s", input.getDriveUuid(), e.getMessage()); - } - return builder.durable(true).type(Volume.Type.NAS).build(); - } - } - - /** - * When we create the boot drive of the server, by convention we set the name - * to the image it came from. - * - * @author Adrian Cole - * - */ - @Singleton - public static class GetImageIdFromServer implements Function { - @Resource - protected Logger logger = Logger.NULL; - - private final LoadingCache cache; - - @Inject - public GetImageIdFromServer(LoadingCache cache) { - this.cache = cache; - } - - @Override - public String apply(Server from) { - String imageId = null; - String bootDeviceId = Iterables.get(from.getBootDeviceIds(), 0); - Device bootDevice = from.getDevices().get(bootDeviceId); - if (bootDevice != null) { - try { - DriveInfo drive = cache.getUnchecked(bootDevice.getDriveUuid()); - imageId = drive.getName(); - } catch (NullPointerException e) { - logger.debug("drive %s not found", bootDevice.getDriveUuid()); - } catch (UncheckedExecutionException e) { - logger.warn(e, "error finding drive %s: %s", bootDevice.getDriveUuid(), e.getMessage()); - } - } - return imageId; - } - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/options/CloudSigmaTemplateOptions.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/options/CloudSigmaTemplateOptions.java deleted file mode 100644 index eac1343791..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/options/CloudSigmaTemplateOptions.java +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.compute.options; - -import org.jclouds.cloudsigma.domain.AffinityType; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.scriptbuilder.domain.Statement; - -import java.util.Map; - -public class CloudSigmaTemplateOptions extends TemplateOptions implements Cloneable { - - public static final CloudSigmaTemplateOptions NONE = new CloudSigmaTemplateOptions(); - - private AffinityType diskDriveAffinity = AffinityType.HDD; - - public CloudSigmaTemplateOptions diskDriveAffinity(AffinityType diskDriveAffinity) { - this.diskDriveAffinity = diskDriveAffinity; - return this; - } - - public AffinityType getDiskDriveAffinity() { - return diskDriveAffinity; - } - - @Override - public CloudSigmaTemplateOptions clone() { - CloudSigmaTemplateOptions options = new CloudSigmaTemplateOptions(); - copyTo(options); - return options; - } - - @Override - public void copyTo(TemplateOptions to) { - super.copyTo(to); - if (to instanceof CloudSigmaTemplateOptions) { - CloudSigmaTemplateOptions cTo = CloudSigmaTemplateOptions.class.cast(to); - cTo.diskDriveAffinity(getDiskDriveAffinity()); - } - } - - public static class Builder { - - /** - * @see CloudSigmaTemplateOptions#diskDriveAffinity - */ - public static CloudSigmaTemplateOptions diskDriveAffinity(AffinityType diskDriveAffinity) { - CloudSigmaTemplateOptions options = new CloudSigmaTemplateOptions(); - return options.diskDriveAffinity(diskDriveAffinity); - } - - // methods that only facilitate returning the correct object type - - /** - * @see TemplateOptions#inboundPorts - */ - public static CloudSigmaTemplateOptions inboundPorts(int... ports) { - CloudSigmaTemplateOptions options = new CloudSigmaTemplateOptions(); - return CloudSigmaTemplateOptions.class.cast(options.inboundPorts(ports)); - } - - /** - * @see TemplateOptions#port - */ - public static CloudSigmaTemplateOptions blockOnPort(int port, int seconds) { - CloudSigmaTemplateOptions options = new CloudSigmaTemplateOptions(); - return CloudSigmaTemplateOptions.class.cast(options.blockOnPort(port, seconds)); - } - - /** - * @see TemplateOptions#installPrivateKey - */ - public static CloudSigmaTemplateOptions installPrivateKey(String rsaKey) { - CloudSigmaTemplateOptions options = new CloudSigmaTemplateOptions(); - return CloudSigmaTemplateOptions.class.cast(options.installPrivateKey(rsaKey)); - } - - /** - * @see TemplateOptions#authorizePublicKey - */ - public static CloudSigmaTemplateOptions authorizePublicKey(String rsaKey) { - CloudSigmaTemplateOptions options = new CloudSigmaTemplateOptions(); - return CloudSigmaTemplateOptions.class.cast(options.authorizePublicKey(rsaKey)); - } - - /** - * @see TemplateOptions#userMetadata(Map) - */ - public static CloudSigmaTemplateOptions userMetadata(Map userMetadata) { - CloudSigmaTemplateOptions options = new CloudSigmaTemplateOptions(); - return CloudSigmaTemplateOptions.class.cast(options.userMetadata(userMetadata)); - } - - /** - * @see TemplateOptions#nodeNames(Iterable) - */ - public static CloudSigmaTemplateOptions nodeNames(Iterable nodeNames) { - CloudSigmaTemplateOptions options = new CloudSigmaTemplateOptions(); - return CloudSigmaTemplateOptions.class.cast(options.nodeNames(nodeNames)); - } - - /** - * @see TemplateOptions#nodeNames(Iterable) - */ - public static CloudSigmaTemplateOptions networks(Iterable networks) { - CloudSigmaTemplateOptions options = new CloudSigmaTemplateOptions(); - return CloudSigmaTemplateOptions.class.cast(options.networks(networks)); - } - - public static CloudSigmaTemplateOptions overrideLoginUser(String user) { - CloudSigmaTemplateOptions options = new CloudSigmaTemplateOptions(); - return options.overrideLoginUser(user); - } - - public static CloudSigmaTemplateOptions overrideLoginPassword(String password) { - CloudSigmaTemplateOptions options = new CloudSigmaTemplateOptions(); - return options.overrideLoginPassword(password); - } - - public static CloudSigmaTemplateOptions overrideLoginPrivateKey(String privateKey) { - CloudSigmaTemplateOptions options = new CloudSigmaTemplateOptions(); - return options.overrideLoginPrivateKey(privateKey); - } - - public static CloudSigmaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo) { - CloudSigmaTemplateOptions options = new CloudSigmaTemplateOptions(); - return options.overrideAuthenticateSudo(authenticateSudo); - } - - public static CloudSigmaTemplateOptions overrideLoginCredentials(LoginCredentials credentials) { - CloudSigmaTemplateOptions options = new CloudSigmaTemplateOptions(); - return options.overrideLoginCredentials(credentials); - } - } - - // methods that only facilitate returning the correct object type - - /** - * {@inheritDoc} - */ - @Override - public CloudSigmaTemplateOptions blockOnPort(int port, int seconds) { - return CloudSigmaTemplateOptions.class.cast(super.blockOnPort(port, seconds)); - } - - /** - * {@inheritDoc} - */ - @Override - public CloudSigmaTemplateOptions inboundPorts(int... ports) { - return CloudSigmaTemplateOptions.class.cast(super.inboundPorts(ports)); - } - - /** - * {@inheritDoc} - */ - @Override - public CloudSigmaTemplateOptions authorizePublicKey(String publicKey) { - return CloudSigmaTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); - } - - /** - * {@inheritDoc} - */ - @Override - public CloudSigmaTemplateOptions installPrivateKey(String privateKey) { - return CloudSigmaTemplateOptions.class.cast(super.installPrivateKey(privateKey)); - } - - /** - * {@inheritDoc} - */ - @Override - public CloudSigmaTemplateOptions blockUntilRunning(boolean blockUntilRunning) { - return CloudSigmaTemplateOptions.class.cast(super.blockUntilRunning(blockUntilRunning)); - } - - /** - * {@inheritDoc} - */ - @Override - public CloudSigmaTemplateOptions dontAuthorizePublicKey() { - return CloudSigmaTemplateOptions.class.cast(super.dontAuthorizePublicKey()); - } - - /** - * {@inheritDoc} - */ - @Override - public CloudSigmaTemplateOptions nameTask(String name) { - return CloudSigmaTemplateOptions.class.cast(super.nameTask(name)); - } - - /** - * {@inheritDoc} - */ - @Override - public CloudSigmaTemplateOptions runAsRoot(boolean runAsRoot) { - return CloudSigmaTemplateOptions.class.cast(super.runAsRoot(runAsRoot)); - } - - /** - * {@inheritDoc} - */ - @Override - public CloudSigmaTemplateOptions runScript(Statement script) { - return CloudSigmaTemplateOptions.class.cast(super.runScript(script)); - } - - /** - * {@inheritDoc} - */ - @Override - public CloudSigmaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials) { - return CloudSigmaTemplateOptions.class.cast(super.overrideLoginCredentials(overridingCredentials)); - } - - /** - * {@inheritDoc} - */ - @Override - public CloudSigmaTemplateOptions overrideLoginPassword(String password) { - return CloudSigmaTemplateOptions.class.cast(super.overrideLoginPassword(password)); - } - - /** - * {@inheritDoc} - */ - @Override - public CloudSigmaTemplateOptions overrideLoginPrivateKey(String privateKey) { - return CloudSigmaTemplateOptions.class.cast(super.overrideLoginPrivateKey(privateKey)); - } - - /** - * {@inheritDoc} - */ - @Override - public CloudSigmaTemplateOptions overrideLoginUser(String loginUser) { - return CloudSigmaTemplateOptions.class.cast(super.overrideLoginUser(loginUser)); - } - - /** - * {@inheritDoc} - */ - @Override - public CloudSigmaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo) { - return CloudSigmaTemplateOptions.class.cast(super.overrideAuthenticateSudo(authenticateSudo)); - } - - /** - * {@inheritDoc} - */ - @Override - public CloudSigmaTemplateOptions userMetadata(Map userMetadata) { - return CloudSigmaTemplateOptions.class.cast(super.userMetadata(userMetadata)); - } - - /** - * {@inheritDoc} - */ - @Override - public CloudSigmaTemplateOptions userMetadata(String key, String value) { - return CloudSigmaTemplateOptions.class.cast(super.userMetadata(key, value)); - } - - /** - * {@inheritDoc} - */ - @Override - public CloudSigmaTemplateOptions nodeNames(Iterable nodeNames) { - return CloudSigmaTemplateOptions.class.cast(super.nodeNames(nodeNames)); - } - - /** - * {@inheritDoc} - */ - @Override - public CloudSigmaTemplateOptions networks(Iterable networks) { - return CloudSigmaTemplateOptions.class.cast(super.networks(networks)); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - - CloudSigmaTemplateOptions that = (CloudSigmaTemplateOptions) o; - - if (diskDriveAffinity != that.diskDriveAffinity) return false; - - return true; - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (diskDriveAffinity != null ? diskDriveAffinity.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "CloudSigmaTemplateOptions{" + - "diskDriveAffinity=" + diskDriveAffinity + - '}'; - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java deleted file mode 100644 index 3773fa3e76..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.config; - -import java.util.List; -import java.util.Map; - -import org.jclouds.cloudsigma.CloudSigmaApi; -import org.jclouds.cloudsigma.domain.Device; -import org.jclouds.cloudsigma.domain.Drive; -import org.jclouds.cloudsigma.domain.DriveData; -import org.jclouds.cloudsigma.domain.DriveMetrics; -import org.jclouds.cloudsigma.domain.NIC; -import org.jclouds.cloudsigma.domain.Server; -import org.jclouds.cloudsigma.domain.ServerMetrics; -import org.jclouds.cloudsigma.functions.BaseDriveToMap; -import org.jclouds.cloudsigma.functions.DriveDataToMap; -import org.jclouds.cloudsigma.functions.MapToDevices; -import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId; -import org.jclouds.cloudsigma.functions.MapToDriveMetrics; -import org.jclouds.cloudsigma.functions.MapToNICs; -import org.jclouds.cloudsigma.functions.MapToServerMetrics; -import org.jclouds.cloudsigma.functions.ServerToMap; -import org.jclouds.cloudsigma.handlers.CloudSigmaErrorHandler; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.annotation.ClientError; -import org.jclouds.http.annotation.Redirection; -import org.jclouds.http.annotation.ServerError; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.config.HttpApiModule; - -import com.google.common.base.Function; -import com.google.inject.TypeLiteral; - -/** - * Configures the CloudSigma connection. - * - * @author Adrian Cole - */ -@ConfiguresRestClient -public class CloudSigmaRestClientModule extends HttpApiModule { - - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(CloudSigmaErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(CloudSigmaErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(CloudSigmaErrorHandler.class); - } - - @Override - protected void configure() { - super.configure(); - bind(new TypeLiteral>>() { - }).to(BaseDriveToMap.class); - bind(new TypeLiteral>>() { - }).to(DriveDataToMap.class); - bind(new TypeLiteral, List>>() { - }).to(MapToNICs.class); - bind(new TypeLiteral, Map>>() { - }).to(MapToDevices.class); - bind(new TypeLiteral, Map>>() { - }).to(MapToDriveMetrics.class); - bind(new TypeLiteral, ServerMetrics>>() { - }).to(MapToServerMetrics.class); - bind(new TypeLiteral>() { - }).to(DeviceToId.class); - bind(new TypeLiteral>>() { - }).to(ServerToMap.class); - } - - @Override - protected void bindRetryHandlers() { - // TODO - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/AffinityType.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/AffinityType.java deleted file mode 100644 index a9ce16f477..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/AffinityType.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Option for the cloneDrive operation. - * 'HDD' to specifies a regular "spinning oxide" disk; 'SSD' specifies a solid-state drive. - * - * @author Alasdair Hodge - */ -public enum AffinityType { - HDD, - SSD, - UNRECOGNIZED; - - public String value() { - return name().toLowerCase(); - } - - @Override - public String toString() { - return value(); - } - - public static AffinityType fromValue(String affinity) { - try { - return valueOf(checkNotNull(affinity, "affinity").toUpperCase()); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/BlockDevice.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/BlockDevice.java deleted file mode 100644 index fd4cf3f955..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/BlockDevice.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkArgument; - -/** - * - * @author Adrian Cole - */ -public class BlockDevice extends Device { - public static class Builder extends Device.Builder { - private final int index; - - public Builder(int index) { - this.index = index; - } - - @Override - public Device build() { - return new BlockDevice(uuid, mediaType, index); - } - - } - - private final int index; - - public BlockDevice(String driveUuid, MediaType mediaType, int index) { - super(driveUuid, mediaType); - checkArgument(index >= 0 && index < 8, "index must be between 0 and 7"); - this.index = index; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + index; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - BlockDevice other = (BlockDevice) obj; - if (index != other.index) - return false; - return true; - } - - @Override - public String getId() { - return String.format("block:%d", index); - } - - public int getIndex() { - return index; - } - - @Override - public String toString() { - return "[id=" + getId() + ", driveUuid=" + driveUuid + ", mediaType=" + mediaType + "]"; - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ClaimType.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ClaimType.java deleted file mode 100644 index 909981b763..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ClaimType.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * either 'exclusive' (the default) or 'shared' to allow multiple servers to access a drive - * simultaneously - * - * @author Adrian Cole - */ -public enum ClaimType { - /** - * - */ - EXCLUSIVE, - /** - * allow multiple servers to access a drive simultaneously - */ - SHARED, UNRECOGNIZED; - - public String value() { - return name().toLowerCase(); - } - - @Override - public String toString() { - return value(); - } - - public static ClaimType fromValue(String claim) { - try { - return valueOf(checkNotNull(claim, "claim").toUpperCase()); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java deleted file mode 100644 index 5af1315425..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -public class CreateDriveRequest extends Drive { - public static class Builder extends Drive.Builder { - - private Set avoid = ImmutableSet.of(); - - @Nullable - private String encryptionCipher; - - public Builder avoid(Iterable avoid) { - this.avoid = ImmutableSet.copyOf(checkNotNull(avoid, "avoid")); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Builder claimType(ClaimType claimType) { - return Builder.class.cast(super.claimType(claimType)); - } - - public Builder encryptionCipher(String encryptionCipher) { - this.encryptionCipher = encryptionCipher; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Builder name(String name) { - return Builder.class.cast(super.name(name)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder tags(Iterable tags) { - return Builder.class.cast(super.tags(tags)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder readers(Iterable readers) { - return Builder.class.cast(super.readers(readers)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder size(long size) { - return Builder.class.cast(super.size(size)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder use(Iterable use) { - return Builder.class.cast(super.use(use)); - } - - public CreateDriveRequest build() { - return new CreateDriveRequest(name, size, claimType, tags, readers, use, encryptionCipher, avoid); - } - } - - private final Set avoid; - @Nullable - private final String encryptionCipher; - - public CreateDriveRequest(String name, long size, @Nullable ClaimType claimType, Iterable tags, - Iterable readers, Iterable use, @Nullable String encryptionCipher, Iterable avoid) { - super(null, name, size, claimType, tags, readers, use); - this.encryptionCipher = encryptionCipher; - this.avoid = ImmutableSet.copyOf(checkNotNull(avoid, "avoid")); - } - - /** - * - * @return list of existing drives to ensure this new drive is created on physical different - * hardware than those existing drives - */ - public Set getAvoid() { - return avoid; - } - - /** - * - * @return either 'none' or 'aes-xts-plain' (the default) - */ - @Nullable - public String getEncryptionCipher() { - return encryptionCipher; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((avoid == null) ? 0 : avoid.hashCode()); - result = prime * result + ((encryptionCipher == null) ? 0 : encryptionCipher.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - CreateDriveRequest other = (CreateDriveRequest) obj; - if (avoid == null) { - if (other.avoid != null) - return false; - } else if (!avoid.equals(other.avoid)) - return false; - if (encryptionCipher == null) { - if (other.encryptionCipher != null) - return false; - } else if (!encryptionCipher.equals(other.encryptionCipher)) - return false; - return true; - } - - @Override - public String toString() { - return "[name=" + name + ", size=" + size + ", claimType=" + claimType + ", tags=" + tags - + ", readers=" + readers + ", use=" + use + ", avoid=" + avoid - + ", encryptionCipher=" + encryptionCipher + "]"; - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Device.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Device.java deleted file mode 100644 index c079386cc6..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Device.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * - * @author Adrian Cole - */ -public abstract class Device { - public abstract static class Builder { - protected String uuid; - protected MediaType mediaType = MediaType.DISK; - - public Builder mediaType(MediaType mediaType) { - this.mediaType = mediaType; - return this; - } - - public Builder uuid(String uuid) { - this.uuid = uuid; - return this; - } - - public abstract Device build(); - } - - protected final String driveUuid; - protected final MediaType mediaType; - - public Device(String driveUuid, MediaType mediaType) { - this.driveUuid = checkNotNull(driveUuid, "driveUuid"); - this.mediaType = checkNotNull(mediaType, "mediaType"); - } - - /** - * id generated based on the device bus, unit, and/or index numbers; - */ - public abstract String getId(); - - /** - * - * @return Drive UUID to connect as specified device. - */ - public String getDriveUuid() { - return driveUuid; - } - - /** - * - * @return set to 'cdrom' to simulate a cdrom, set to 'disk' or leave unset to simulate a hard - * disk. - */ - public MediaType getMediaType() { - return mediaType; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((driveUuid == null) ? 0 : driveUuid.hashCode()); - result = prime * result + ((mediaType == null) ? 0 : mediaType.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Device other = (Device) obj; - if (driveUuid == null) { - if (other.driveUuid != null) - return false; - } else if (!driveUuid.equals(other.driveUuid)) - return false; - if (mediaType != other.mediaType) - return false; - return true; - } - - @Override - public String toString() { - return "[driveUuid=" + driveUuid + ", mediaType=" + mediaType + "]"; - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java deleted file mode 100644 index 0aad6aaaf4..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -public class Drive extends Item { - public static class Builder extends Item.Builder { - protected long size; - protected ClaimType claimType = ClaimType.EXCLUSIVE; - protected Set tags = ImmutableSet.of(); - protected Set readers = ImmutableSet.of(); - - public Builder claimType(ClaimType claimType) { - this.claimType = claimType; - return this; - } - - public Builder tags(Iterable tags) { - this.tags = ImmutableSet.copyOf(checkNotNull(tags, "tags")); - return this; - } - - public Builder readers(Iterable readers) { - this.readers = ImmutableSet.copyOf(checkNotNull(readers, "readers")); - return this; - } - - public Builder size(long size) { - this.size = size; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Builder uuid(String uuid) { - return Builder.class.cast(super.uuid(uuid)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder name(String name) { - return Builder.class.cast(super.name(name)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder use(Iterable use) { - return Builder.class.cast(super.use(use)); - } - - public Drive build() { - return new Drive(uuid, name, size, claimType, tags, readers, use); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((claimType == null) ? 0 : claimType.hashCode()); - result = prime * result + ((tags == null) ? 0 : tags.hashCode()); - result = prime * result + ((readers == null) ? 0 : readers.hashCode()); - result = prime * result + (int) (size ^ (size >>> 32)); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - Builder other = (Builder) obj; - if (claimType != other.claimType) - return false; - if (!Objects.equal(tags, other.tags)) - return false; - if (!Objects.equal(readers, other.readers)) - return false; - if (size != other.size) - return false; - return true; - } - } - - protected final long size; - protected final ClaimType claimType; - protected final Set tags; - protected final Set readers; - - public Drive(@Nullable String uuid, String name, long size, @Nullable ClaimType claimType, - Iterable tags, Iterable readers, Iterable use) { - super(uuid, name, use); - this.size = size; - this.claimType = checkNotNull(claimType, "set claimType to exclusive, not null"); - this.tags = ImmutableSet.copyOf(checkNotNull(tags, "tags")); - this.readers = ImmutableSet.copyOf(checkNotNull(readers, "readers")); - } - - /** - * - * @return either 'exclusive' (the default) or 'shared' to allow multiple servers to access a - * drive simultaneously - */ - @Nullable - public ClaimType getClaimType() { - return claimType; - } - - /** - * @return all tags associated with this drive, both user-specified and "system" tags (e.g. "affinity:ssd") - */ - public Set getTags() { - return tags; - } - - /** - * - * @return list of users allowed to read from a drive or 'ffffffff-ffff-ffff-ffff-ffffffffffff' - * for all users - */ - public Set getReaders() { - return readers; - } - - /** - * - * @return size of drive in bytes - */ - public long getSize() { - return size; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((claimType == null) ? 0 : claimType.hashCode()); - result = prime * result + ((tags == null) ? 0 : tags.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((readers == null) ? 0 : readers.hashCode()); - result = prime * result + (int) (size ^ (size >>> 32)); - result = prime * result + ((use == null) ? 0 : use.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Drive other = (Drive) obj; - if (claimType != other.claimType) - return false; - if (!Objects.equal(tags, other.tags)) - return false; - if (!Objects.equal(name, other.name)) - return false; - if (!Objects.equal(readers, other.readers)) - return false; - if (size != other.size) - return false; - if (use == null) { - if (other.use != null) - return false; - } else if (!use.equals(other.use)) - return false; - return true; - } - - @Override - public String toString() { - return "[uuid=" + uuid + ", name=" + name + ", use=" + use + ", size=" + size + ", claimType=" + claimType - + ", tags=" + tags + ", readers=" + readers + "]"; - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java deleted file mode 100644 index 05cc0167c8..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import org.jclouds.javax.annotation.Nullable; - -/** - * - * @author Adrian Cole - */ -public class DriveData extends Drive { - public static class Builder extends Drive.Builder { - - /** - * {@inheritDoc} - */ - @Override - public Builder claimType(ClaimType claimType) { - return Builder.class.cast(super.claimType(claimType)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder name(String name) { - return Builder.class.cast(super.name(name)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder tags(Iterable tags) { - return Builder.class.cast(super.tags(tags)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder readers(Iterable readers) { - return Builder.class.cast(super.readers(readers)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder size(long size) { - return Builder.class.cast(super.size(size)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder use(Iterable use) { - return Builder.class.cast(super.use(use)); - } - - public DriveData build() { - return new DriveData(uuid, name, size, claimType, tags, readers, use); - } - } - - public DriveData(@Nullable String uuid, String name, long size, @Nullable ClaimType claimType, - Iterable tags, Iterable readers, Iterable use) { - super(uuid, name, size, claimType, tags, readers, use); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java deleted file mode 100644 index e61fc282f9..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java +++ /dev/null @@ -1,470 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -public class DriveInfo extends Drive { - public static class Builder extends Drive.Builder { - - protected DriveStatus status; - protected String user; - protected Set claimed = ImmutableSet.of(); - @Nullable - protected String encryptionCipher; - @Nullable - protected String imaging; - protected DriveMetrics metrics; - private Boolean autoexpanding; - private Integer bits; - private String description; - private Set driveType = ImmutableSet.of(); - private String encryptionKey; - private Boolean free; - private String installNotes; - private String os; - private DriveType type; - private URI url; - - public Builder status(DriveStatus status) { - this.status = status; - return this; - } - - public Builder user(String user) { - this.user = user; - return this; - } - - public Builder claimed(Iterable claimed) { - this.claimed = ImmutableSet.copyOf(checkNotNull(claimed, "claimed")); - return this; - } - - public Builder imaging(String imaging) { - this.imaging = imaging; - return this; - } - - public Builder metrics(DriveMetrics metrics) { - this.metrics = metrics; - return this; - } - - public Builder encryptionCipher(String encryptionCipher) { - this.encryptionCipher = encryptionCipher; - return this; - } - - public Builder autoexpanding(Boolean autoexpanding) { - this.autoexpanding = autoexpanding; - return this; - } - - public Builder bits(Integer bits) { - this.bits = bits; - return this; - } - - public Builder description(String description) { - this.description = description; - return this; - } - - public Builder driveType(Iterable driveType) { - this.driveType = ImmutableSet.copyOf(checkNotNull(driveType, "driveType")); - return this; - } - - public Builder encryptionKey(String encryptionKey) { - this.encryptionKey = encryptionKey; - return this; - } - - public Builder free(Boolean free) { - this.free = free; - return this; - } - - public Builder installNotes(String installNotes) { - this.installNotes = installNotes; - return this; - } - - public Builder os(String os) { - this.os = os; - return this; - } - - public Builder type(DriveType type) { - this.type = type; - return this; - } - - public Builder url(URI url) { - this.url = url; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Builder claimType(ClaimType claimType) { - return Builder.class.cast(super.claimType(claimType)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder tags(Iterable tags) { - return Builder.class.cast(super.tags(tags)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder readers(Iterable readers) { - return Builder.class.cast(super.readers(readers)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder size(long size) { - return Builder.class.cast(super.size(size)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder uuid(String uuid) { - return Builder.class.cast(super.uuid(uuid)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder name(String name) { - return Builder.class.cast(super.name(name)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder use(Iterable use) { - return Builder.class.cast(super.use(use)); - } - - public static Builder fromDriveInfo(DriveInfo in) { - return new Builder().uuid(in.getUuid()).name(in.getName()).size(in.getSize()).claimType(in.getClaimType()) - .readers(in.getReaders()).use(in.getUse()).status(in.getStatus()).user(in.getUser()) - .claimed(in.getClaimed()).encryptionCipher(in.getEncryptionCipher()).imaging(in.getImaging()) - .metrics(in.getMetrics()).autoexpanding(in.getAutoexpanding()).bits(in.getBits()) - .description(in.getDescription()).encryptionKey(in.getEncryptionKey()).free(in.getFree()) - .installNotes(in.getInstallNotes()).type(in.getType()).url(in.getUrl()); - } - - /** - * {@inheritDoc} - */ - @Override - public DriveInfo build() { - return new DriveInfo(uuid, name, size, claimType, tags, readers, use, status, user, claimed, encryptionCipher, - imaging, metrics, autoexpanding, bits, description, driveType, encryptionKey, free, installNotes, os, - type, url); - } - - } - - protected final DriveStatus status; - protected final String user; - protected final Set claimed; - @Nullable - protected final String encryptionCipher; - @Nullable - protected final String imaging; - protected final DriveMetrics metrics; - private final Boolean autoexpanding; - private final Integer bits; - private final String description; - private final ImmutableSet driveType; - private final String encryptionKey; - private final Boolean free; - private final String installNotes; - private final String os; - private final DriveType type; - private final URI url; - - public DriveInfo(String uuid, String name, long size, ClaimType claimType, Iterable tags, Iterable readers, - Iterable use, DriveStatus status, String user, Set claimed, String encryptionCipher, - String imaging, DriveMetrics metrics, Boolean autoexpanding, Integer bits, String description, - Iterable driveType, String encryptionKey, Boolean free, String installNotes, String os, - DriveType type, URI url) { - super(uuid, name, size, claimType, tags, readers, use); - this.status = status; - this.user = user; - this.claimed = ImmutableSet.copyOf(checkNotNull(claimed, "claimed")); - this.encryptionCipher = encryptionCipher; - this.imaging = imaging; - this.metrics = checkNotNull(metrics, "metrics"); - this.autoexpanding = autoexpanding; - this.bits = bits; - this.description = description; - this.driveType = ImmutableSet.copyOf(driveType); - this.encryptionKey = encryptionKey; - this.free = free; - this.installNotes = installNotes; - this.os = os; - this.type = type; - this.url = url; - } - - /** - * - * @return current status of the drive - */ - public DriveStatus getStatus() { - return status; - } - - /** - * - * @return owner of the drive - */ - public String getUser() { - return user; - } - - /** - * - * @return if drive is in use by a server, values are the server uuids - */ - public Set getClaimed() { - return claimed; - } - - /** - * - * @return either 'none' or 'aes-xts-plain' (the default) - */ - @Nullable - public String getEncryptionCipher() { - return encryptionCipher; - } - - /** - * - * @return percentage completed of drive imaging if this is underway, or 'queued' if waiting for - * another imaging operation to complete first - */ - public String getImaging() { - return imaging; - } - - /** - * - * @return i/o and request metrics for read and write ops - */ - public DriveMetrics getMetrics() { - return metrics; - } - - // TODO - public Boolean getAutoexpanding() { - return autoexpanding; - } - - // TODO - public Integer getBits() { - return bits; - } - - // TODO undocumented - public String getDescription() { - return description; - } - - // TODO - public Set getDriveType() { - return driveType; - } - - // TODO - public String getEncryptionKey() { - return encryptionKey; - } - - // TODO - public Boolean getFree() { - return free; - } - - // TODO - public String getInstallNotes() { - return installNotes; - } - - // TODO - public String getOs() { - return os; - } - - // TODO - public DriveType getType() { - return type; - } - - public URI getUrl() { - return url; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((autoexpanding == null) ? 0 : autoexpanding.hashCode()); - result = prime * result + ((bits == null) ? 0 : bits.hashCode()); - result = prime * result + ((claimed == null) ? 0 : claimed.hashCode()); - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((driveType == null) ? 0 : driveType.hashCode()); - result = prime * result + ((encryptionCipher == null) ? 0 : encryptionCipher.hashCode()); - result = prime * result + ((encryptionKey == null) ? 0 : encryptionKey.hashCode()); - result = prime * result + ((free == null) ? 0 : free.hashCode()); - result = prime * result + ((imaging == null) ? 0 : imaging.hashCode()); - result = prime * result + ((installNotes == null) ? 0 : installNotes.hashCode()); - result = prime * result + ((metrics == null) ? 0 : metrics.hashCode()); - result = prime * result + ((os == null) ? 0 : os.hashCode()); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - result = prime * result + ((url == null) ? 0 : url.hashCode()); - result = prime * result + ((user == null) ? 0 : user.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - DriveInfo other = (DriveInfo) obj; - if (autoexpanding == null) { - if (other.autoexpanding != null) - return false; - } else if (!autoexpanding.equals(other.autoexpanding)) - return false; - if (bits == null) { - if (other.bits != null) - return false; - } else if (!bits.equals(other.bits)) - return false; - if (claimed == null) { - if (other.claimed != null) - return false; - } else if (!claimed.equals(other.claimed)) - return false; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (driveType == null) { - if (other.driveType != null) - return false; - } else if (!driveType.equals(other.driveType)) - return false; - if (encryptionCipher == null) { - if (other.encryptionCipher != null) - return false; - } else if (!encryptionCipher.equals(other.encryptionCipher)) - return false; - if (encryptionKey == null) { - if (other.encryptionKey != null) - return false; - } else if (!encryptionKey.equals(other.encryptionKey)) - return false; - if (free == null) { - if (other.free != null) - return false; - } else if (!free.equals(other.free)) - return false; - if (imaging == null) { - if (other.imaging != null) - return false; - } else if (!imaging.equals(other.imaging)) - return false; - if (installNotes == null) { - if (other.installNotes != null) - return false; - } else if (!installNotes.equals(other.installNotes)) - return false; - if (metrics == null) { - if (other.metrics != null) - return false; - } else if (!metrics.equals(other.metrics)) - return false; - if (os == null) { - if (other.os != null) - return false; - } else if (!os.equals(other.os)) - return false; - if (status != other.status) - return false; - if (type != other.type) - return false; - if (url == null) { - if (other.url != null) - return false; - } else if (!url.equals(other.url)) - return false; - if (user == null) { - if (other.user != null) - return false; - } else if (!user.equals(other.user)) - return false; - return true; - } - - @Override - public String toString() { - return "[size=" + size + ", claimType=" + claimType + ", tags=" + tags + ", readers=" + readers - + ", uuid=" + uuid + ", name=" + name + ", use=" + use + ", status=" + status - + ", user=" + user + ", claimed=" + claimed + ", encryptionCipher=" + encryptionCipher - + ", imaging=" + imaging + ", metrics=" + metrics + "]"; - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveMetrics.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveMetrics.java deleted file mode 100644 index 4c9df61c94..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveMetrics.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - - -/** - * - * @author Adrian Cole - */ -public class DriveMetrics { - public static class Builder { - protected long readBytes; - protected long readRequests; - protected long writeBytes; - protected long writeRequests; - - public Builder readBytes(long readBytes) { - this.readBytes = readBytes; - return this; - } - - public Builder readRequests(long readRequests) { - this.readRequests = readRequests; - return this; - } - - public Builder writeBytes(long writeBytes) { - this.writeBytes = writeBytes; - return this; - } - - public Builder writeRequests(long writeRequests) { - this.writeRequests = writeRequests; - return this; - } - - public DriveMetrics build() { - return new DriveMetrics(readBytes, readRequests, writeBytes, writeRequests); - } - } - - protected final long readBytes; - protected final long readRequests; - protected final long writeBytes; - protected final long writeRequests; - - public DriveMetrics(long readBytes, long readRequests, long writeBytes, long writeRequests) { - this.readBytes = readBytes; - this.readRequests = readRequests; - this.writeBytes = writeBytes; - this.writeRequests = writeRequests; - } - - /** - * - * @return Cumulative i/o byte/request count for each drive - */ - public long getReadBytes() { - return readBytes; - } - - /** - * - * @return Cumulative i/o byte/request count for each drive - */ - public long getReadRequests() { - return readRequests; - } - - /** - * - * @return Cumulative i/o byte/request count for each drive - */ - public long getWriteBytes() { - return writeBytes; - } - - /** - * - * @return Cumulative i/o byte/request count for each drive - */ - public long getWriteRequests() { - return writeRequests; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (readBytes ^ (readBytes >>> 32)); - result = prime * result + (int) (readRequests ^ (readRequests >>> 32)); - result = prime * result + (int) (writeBytes ^ (writeBytes >>> 32)); - result = prime * result + (int) (writeRequests ^ (writeRequests >>> 32)); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - DriveMetrics other = (DriveMetrics) obj; - if (readBytes != other.readBytes) - return false; - if (readRequests != other.readRequests) - return false; - if (writeBytes != other.writeBytes) - return false; - if (writeRequests != other.writeRequests) - return false; - return true; - } - - @Override - public String toString() { - return "[readBytes=" + readBytes + ", readRequests=" + readRequests + ", writeBytes=" + writeBytes - + ", writeRequests=" + writeRequests + "]"; - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveStatus.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveStatus.java deleted file mode 100644 index c845d7847a..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveStatus.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * - * @author Adrian Cole - */ -public enum DriveStatus { - ACTIVE, INACTIVE, COPYING, IMAGING, UNRECOGNIZED; - - public String value() { - return name().toLowerCase(); - } - - @Override - public String toString() { - return value(); - } - - public static DriveStatus fromValue(String status) { - try { - return valueOf(checkNotNull(status, "status").toUpperCase()); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveType.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveType.java deleted file mode 100644 index 25daa0fe69..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveType.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * - * @author Adrian Cole - */ -public enum DriveType { - DISK, CDROM, SHARED, UNRECOGNIZED; - - public String value() { - return name().toLowerCase(); - } - - @Override - public String toString() { - return value(); - } - - public static DriveType fromValue(String type) { - try { - return valueOf(checkNotNull(type, "type").toUpperCase()); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/IDEDevice.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/IDEDevice.java deleted file mode 100644 index 4fb8ba9457..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/IDEDevice.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkArgument; - -/** - * - * @author Adrian Cole - */ -public class IDEDevice extends Device { - public static class Builder extends Device.Builder { - private final int bus; - private final int unit; - - public Builder(int bus, int unit) { - this.bus = bus; - this.unit = unit; - } - - @Override - public Device build() { - return new IDEDevice(uuid, mediaType, bus, unit); - } - - } - - private final int bus; - private final int unit; - - public IDEDevice(String driveUuid, MediaType mediaType, int bus, int unit) { - super(driveUuid, mediaType); - checkArgument(bus == 0 || bus == 1, "bus must be 0 or 1"); - checkArgument(unit == 0 || unit == 1, "unit must be 0 or 1"); - this.bus = bus; - this.unit = unit; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + bus; - result = prime * result + unit; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - IDEDevice other = (IDEDevice) obj; - if (bus != other.bus) - return false; - if (unit != other.unit) - return false; - return true; - } - - @Override - public String getId() { - return String.format("ide:%d:%d", bus, unit); - } - - public int getBus() { - return bus; - } - - public int getUnit() { - return unit; - } - - @Override - public String toString() { - return "[id=" + getId() + ", driveUuid=" + driveUuid + ", mediaType=" + mediaType + "]"; - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Item.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Item.java deleted file mode 100644 index 7214f3330c..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Item.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -public class Item { - public static class Builder { - protected String uuid; - protected String name; - protected Set use = ImmutableSet.of(); - - public Builder uuid(String uuid) { - this.uuid = uuid; - return this; - } - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder use(Iterable use) { - this.use = ImmutableSet.copyOf(checkNotNull(use, "use")); - return this; - } - - public Item build() { - return new Item(uuid, name, use); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((use == null) ? 0 : use.hashCode()); - result = prime * result + ((uuid == null) ? 0 : uuid.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Builder other = (Builder) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (use == null) { - if (other.use != null) - return false; - } else if (!use.equals(other.use)) - return false; - if (uuid == null) { - if (other.uuid != null) - return false; - } else if (!uuid.equals(other.uuid)) - return false; - return true; - } - } - - @Nullable - protected final String uuid; - protected final String name; - protected final Set use; - - public Item(@Nullable String uuid, String name, Iterable use) { - this.uuid = uuid; - this.name = checkNotNull(name, "name"); - this.use = ImmutableSet.copyOf(checkNotNull(use, "use")); - } - - /** - * - * @return uuid of the item. - */ - @Nullable - public String getUuid() { - return uuid; - } - - /** - * - * @return name of the item - */ - public String getName() { - return name; - } - - /** - * - * @return list of use - */ - public Set getUse() { - return use; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((use == null) ? 0 : use.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Item other = (Item) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (use == null) { - if (other.use != null) - return false; - } else if (!use.equals(other.use)) - return false; - - return true; - } - - @Override - public String toString() { - return "[uuid=" + uuid + ", name=" + name + ", use=" + use + "]"; - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/MediaType.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/MediaType.java deleted file mode 100644 index 894807b7e8..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/MediaType.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Media type - set to 'cdrom' to simulate a cdrom, set to 'disk' or leave unset to simulate a hard - * disk. - * - * @author Adrian Cole - */ -public enum MediaType { - DISK, CDROM, UNRECOGNIZED; - - public String value() { - return name().toLowerCase(); - } - - @Override - public String toString() { - return value(); - } - - public static MediaType fromValue(String type) { - try { - return valueOf(checkNotNull(type, "type").toUpperCase()); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Model.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Model.java deleted file mode 100644 index 5626f55cc5..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Model.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * - * @author Adrian Cole - */ -public enum Model { - E1000, RTl8139, VIRTIO, UNRECOGNIZED; - - public String value() { - return name().toLowerCase(); - } - - @Override - public String toString() { - return value(); - } - - public static Model fromValue(String model) { - try { - return valueOf(checkNotNull(model, "model").toUpperCase()); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/NIC.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/NIC.java deleted file mode 100644 index b25fb0472f..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/NIC.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -public class NIC { - public static class Builder { - private String dhcp; - private Model model; - private String vlan; - private String mac; - // TODO cloudsigma specific - private Set block = ImmutableSet.of(); - - public Builder dhcp(String dhcp) { - this.dhcp = dhcp; - return this; - } - - public Builder model(Model model) { - this.model = model; - return this; - } - - public Builder vlan(String vlan) { - this.vlan = vlan; - return this; - } - - public Builder mac(String mac) { - this.mac = mac; - return this; - } - - public Builder block(Iterable block) { - this.block = ImmutableSet.copyOf(checkNotNull(block, "block")); - return this; - } - - public NIC build() { - return new NIC(dhcp, model, vlan, mac, block); - } - } - - private final String dhcp; - private final Model model; - private final String vlan; - private final String mac; - private final Set block; - - public NIC(@Nullable String dhcp, Model model, @Nullable String vlan, @Nullable String mac, Iterable block) { - this.dhcp = dhcp; - this.model = checkNotNull(model, "model"); - this.vlan = vlan; - this.mac = mac; - this.block = ImmutableSet.copyOf(checkNotNull(block, "block")); - } - - /** - * - * @return The IP address offered by DHCP to network interface 0. If unset, no address is - * offered. Set to 'auto' to allocate a temporary IP at boot. - */ - public String getDhcp() { - return dhcp; - } - - /** - * - * @return Create network interface with given type (use 'e1000' as default value; 'rtl8139' or - * 'virtio' are also available). - */ - public Model getModel() { - return model; - } - - /** - * - * @return The VLAN to which the network interface is attached. - */ - public String getVlan() { - return vlan; - } - - /** - * - * @return The MAC address of the network interface. If unset, a randomly generated address is - * used. If set, should be unique on the VLAN. - */ - public String getMac() { - return mac; - } - - // TODO undocumented - public Set getBlock() { - return block; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((block == null) ? 0 : block.hashCode()); - result = prime * result + ((dhcp == null) ? 0 : dhcp.hashCode()); - result = prime * result + ((mac == null) ? 0 : mac.hashCode()); - result = prime * result + ((model == null) ? 0 : model.hashCode()); - result = prime * result + ((vlan == null) ? 0 : vlan.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NIC other = (NIC) obj; - if (block == null) { - if (other.block != null) - return false; - } else if (!block.equals(other.block)) - return false; - if (dhcp == null) { - if (other.dhcp != null) - return false; - } else if (!dhcp.equals(other.dhcp)) - return false; - if (mac == null) { - if (other.mac != null) - return false; - } else if (!mac.equals(other.mac)) - return false; - if (model != other.model) - return false; - if (vlan == null) { - if (other.vlan != null) - return false; - } else if (!vlan.equals(other.vlan)) - return false; - return true; - } - - @Override - public String toString() { - return "[dhcp=" + dhcp + ", model=" + model + ", vlan=" + vlan + ", mac=" + mac + ", block=" + block + "]"; - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ProfileInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ProfileInfo.java deleted file mode 100644 index 03d73bc6d2..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ProfileInfo.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * - * @author Adrian Cole - */ -public class ProfileInfo { - - public static class Builder { - protected String uuid; - protected String email; - protected String firstName; - protected String lastName; - protected String nickName; - protected ProfileType type = ProfileType.REGULAR; - - public Builder uuid(String uuid) { - this.uuid = uuid; - return this; - } - - public Builder email(String email) { - this.email = email; - return this; - } - - public Builder firstName(String firstName) { - this.firstName = firstName; - return this; - } - - public Builder lastName(String lastName) { - this.lastName = lastName; - return this; - } - - public Builder nickName(String nickName) { - this.nickName = nickName; - return this; - } - - public Builder type(ProfileType type) { - this.type = type; - return this; - } - - public ProfileInfo build() { - return new ProfileInfo(uuid, email, firstName, lastName, nickName, type); - } - - } - - protected final String uuid; - protected final String email; - protected final String firstName; - protected final String lastName; - protected final String nickName; - protected final ProfileType type; - - public ProfileInfo(String uuid, String email, String firstName, String lastName, String nickName, ProfileType type) { - this.uuid = checkNotNull(uuid, "uuid"); - this.email = checkNotNull(email, "email"); - this.firstName = checkNotNull(firstName, "firstName"); - this.lastName = checkNotNull(lastName, "lastName"); - this.nickName = checkNotNull(nickName, "nickName"); - this.type = checkNotNull(type, "type"); - } - - /** - * - * @return uuid of the profile. - */ - public String getUuid() { - return uuid; - } - - /** - * Checks for valid email address - * - * @return email of the profile. - */ - public String getEmail() { - return email; - } - - /** - * - * @return firstName of the profile. - */ - protected String getFirstName() { - return firstName; - } - - /** - * - * @return lastName of the profile. - */ - protected String getLastName() { - return lastName; - } - - /** - * Used in phpBB nick name - * - * @return nickName of the profile. - */ - protected String getNickName() { - return nickName; - } - - /** - * - * @return type of the profile. - */ - protected ProfileType getType() { - return type; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((email == null) ? 0 : email.hashCode()); - result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); - result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); - result = prime * result + ((nickName == null) ? 0 : nickName.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - result = prime * result + ((uuid == null) ? 0 : uuid.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ProfileInfo other = (ProfileInfo) obj; - if (email == null) { - if (other.email != null) - return false; - } else if (!email.equals(other.email)) - return false; - if (firstName == null) { - if (other.firstName != null) - return false; - } else if (!firstName.equals(other.firstName)) - return false; - if (lastName == null) { - if (other.lastName != null) - return false; - } else if (!lastName.equals(other.lastName)) - return false; - if (nickName == null) { - if (other.nickName != null) - return false; - } else if (!nickName.equals(other.nickName)) - return false; - if (type != other.type) - return false; - if (uuid == null) { - if (other.uuid != null) - return false; - } else if (!uuid.equals(other.uuid)) - return false; - return true; - } - - @Override - public String toString() { - return "[uuid=" + uuid + ", email=" + email + ", firstName=" + firstName + ", lastName=" + lastName - + ", nickName=" + nickName + ", type=" + type + "]"; - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ProfileType.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ProfileType.java deleted file mode 100644 index 9e0315f9a9..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ProfileType.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * - * @author Adrian Cole - */ -public enum ProfileType { - REGULAR, UNRECOGNIZED; - public String value() { - return name().toLowerCase(); - } - - @Override - public String toString() { - return value(); - } - - public static ProfileType fromValue(String type) { - try { - return valueOf(checkNotNull(type, "type").toUpperCase()); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/SCSIDevice.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/SCSIDevice.java deleted file mode 100644 index b396057aee..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/SCSIDevice.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkArgument; - -/** - * - * @author Adrian Cole - */ -public class SCSIDevice extends Device { - public static class Builder extends Device.Builder { - private final int unit; - - public Builder(int unit) { - this.unit = unit; - } - - @Override - public Device build() { - return new SCSIDevice(uuid, mediaType, unit); - } - - } - - private static final int bus = 0; - private final int unit; - - public SCSIDevice(String driveUuid, MediaType mediaType, int unit) { - super(driveUuid, mediaType); - checkArgument(unit >= 0 && unit < 8, "unit must be between 0 and 7"); - this.unit = unit; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + bus; - result = prime * result + unit; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SCSIDevice other = (SCSIDevice) obj; - if (unit != other.unit) - return false; - return true; - } - - public int getBus() { - return bus; - } - - public int getUnit() { - return unit; - } - - @Override - public String getId() { - return String.format("scsi:%d:%d", bus, unit); - } - - @Override - public String toString() { - return "[id=" + getId() + ", driveUuid=" + driveUuid + ", mediaType=" + mediaType + "]"; - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Server.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Server.java deleted file mode 100644 index a2b3bbf4dd..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Server.java +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -public class Server extends Item { - - public static class Builder extends Item.Builder { - protected int cpu; - protected Integer smp; - protected int mem; - protected boolean persistent; - protected Map devices = ImmutableMap.of(); - protected Set bootDeviceIds = ImmutableSet.of(); - protected List nics = ImmutableList.of(); - protected VNC vnc; - // TODO cloudsigma specific - protected String description; - - public Builder cpu(int cpu) { - this.cpu = cpu; - return this; - } - - public Builder smp(Integer smp) { - this.smp = smp; - return this; - } - - public Builder mem(int mem) { - this.mem = mem; - return this; - } - - public Builder persistent(boolean persistent) { - this.persistent = persistent; - return this; - } - - public Builder devices(Map devices) { - this.devices = ImmutableMap.copyOf(checkNotNull(devices, "devices")); - return this; - } - - public Builder bootDeviceIds(Iterable bootDeviceIds) { - this.bootDeviceIds = ImmutableSet.copyOf(checkNotNull(bootDeviceIds, "bootDeviceIds")); - return this; - } - - public Builder nics(Iterable nics) { - this.nics = ImmutableList.copyOf(checkNotNull(nics, "nics")); - return this; - } - - public Builder vnc(VNC vnc) { - this.vnc = vnc; - return this; - } - - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Builder uuid(String uuid) { - return Builder.class.cast(super.uuid(uuid)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder name(String name) { - return Builder.class.cast(super.name(name)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder use(Iterable use) { - return Builder.class.cast(super.use(use)); - } - - public Server build() { - return new Server(uuid, name, cpu, smp, mem, persistent, devices, bootDeviceIds, use, nics, vnc, description); - } - - public static Builder fromServer(Server in) { - return new Builder().uuid(in.getUuid()).name(in.getName()).cpu(in.getCpu()).mem(in.getMem()) - .persistent(in.isPersistent()).description(in.getDescription()).devices(in.getDevices()) - .bootDeviceIds(in.getBootDeviceIds()).use(in.getUse()).nics(in.getNics()).vnc(in.getVnc()); - } - } - - protected final int cpu; - protected final Integer smp; - protected final int mem; - protected final boolean persistent; - @Nullable - protected final Map devices; - protected final Set bootDeviceIds; - protected final List nics; - protected final VNC vnc; - @Nullable - private final String description; - - public Server(@Nullable String uuid, String name, int cpu, @Nullable Integer smp, int mem, boolean persistent, - Map devices, Iterable bootDeviceIds, Iterable use, - Iterable nics, VNC vnc, String description) { - super(uuid, name, use); - this.cpu = cpu; - this.smp = smp; - this.mem = mem; - this.persistent = persistent; - this.devices = ImmutableMap.copyOf(checkNotNull(devices, "devices")); - this.bootDeviceIds = ImmutableSet.copyOf(checkNotNull(bootDeviceIds, "bootDeviceIds")); - this.nics = ImmutableList.copyOf(checkNotNull(nics, "nics")); - this.vnc = checkNotNull(vnc, "vnc"); - this.description = description; - } - - /** - * - * @return CPU quota in core MHz. - */ - public int getCpu() { - return cpu; - } - - /** - * - * @return number of virtual processors or null if calculated based on cpu. - */ - public Integer getSmp() { - return smp; - } - - /** - * - * @return virtual memory size in MB. - */ - public int getMem() { - return mem; - } - - /** - * - * @return 'true' means that server will revert to a 'stopped' status on server stop or shutdown, - * rather than being destroyed automatically. - */ - public boolean isPersistent() { - return persistent; - } - - /** - * - * @return devices present, mapped by id - */ - public Map getDevices() { - return devices; - } - - /** - * - * @return ids of the devices to boot, e.g. ide:0:0 or ide:1:0 - * @see Device#getId() - */ - public Set getBootDeviceIds() { - return bootDeviceIds; - } - - public List getNics() { - return nics; - } - - public VNC getVnc() { - return vnc; - } - - // TODO undocumented - public String getDescription() { - return description; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((bootDeviceIds == null) ? 0 : bootDeviceIds.hashCode()); - result = prime * result + cpu; - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((devices == null) ? 0 : devices.hashCode()); - result = prime * result + mem; - result = prime * result + ((nics == null) ? 0 : nics.hashCode()); - result = prime * result + (persistent ? 1231 : 1237); - result = prime * result + ((smp == null) ? 0 : smp.hashCode()); - result = prime * result + ((vnc == null) ? 0 : vnc.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - Server other = (Server) obj; - if (bootDeviceIds == null) { - if (other.bootDeviceIds != null) - return false; - } else if (!bootDeviceIds.equals(other.bootDeviceIds)) - return false; - if (cpu != other.cpu) - return false; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (devices == null) { - if (other.devices != null) - return false; - } else if (!devices.equals(other.devices)) - return false; - if (mem != other.mem) - return false; - if (nics == null) { - if (other.nics != null) - return false; - } else if (!nics.equals(other.nics)) - return false; - if (persistent != other.persistent) - return false; - if (smp == null) { - if (other.smp != null) - return false; - } else if (!smp.equals(other.smp)) - return false; - if (vnc == null) { - if (other.vnc != null) - return false; - } else if (!vnc.equals(other.vnc)) - return false; - return true; - } - - @Override - public String toString() { - return "[uuid=" + uuid + ", name=" + name + ", use=" + use + ", cpu=" + cpu + ", smp=" + smp + ", mem=" + mem - + ", persistent=" + persistent + ", devices=" + devices + ", bootDeviceIds=" + bootDeviceIds + ", nics=" - + nics + ", vnc=" + vnc + ", description=" + description + "]"; - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerInfo.java deleted file mode 100644 index 35023702f0..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerInfo.java +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import java.util.Date; -import java.util.Map; - -import org.jclouds.javax.annotation.Nullable; - -/** - * - * @author Adrian Cole - */ -public class ServerInfo extends Server { - - public static class Builder extends Server.Builder { - protected ServerStatus status; - protected Date started; - protected String user; - protected ServerMetrics metrics; - - public Builder status(ServerStatus status) { - this.status = status; - return this; - } - - public Builder started(Date started) { - this.started = started; - return this; - } - - public Builder user(String user) { - this.user = user; - return this; - } - - public Builder metrics(ServerMetrics metrics) { - this.metrics = metrics; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public Builder cpu(int cpu) { - return Builder.class.cast(super.cpu(cpu)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder smp(Integer smp) { - return Builder.class.cast(super.smp(smp)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder mem(int mem) { - return Builder.class.cast(super.mem(mem)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder persistent(boolean persistent) { - return Builder.class.cast(super.persistent(persistent)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder devices(Map devices) { - return Builder.class.cast(super.devices(devices)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder bootDeviceIds(Iterable bootDeviceIds) { - return Builder.class.cast(super.bootDeviceIds(bootDeviceIds)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder nics(Iterable nics) { - return Builder.class.cast(super.nics(nics)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder vnc(VNC vnc) { - return Builder.class.cast(super.vnc(vnc)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder description(String description) { - return Builder.class.cast(super.description(description)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder uuid(String uuid) { - return Builder.class.cast(super.uuid(uuid)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder name(String name) { - return Builder.class.cast(super.name(name)); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder use(Iterable use) { - return Builder.class.cast(super.use(use)); - } - - public ServerInfo build() { - return new ServerInfo(uuid, name, cpu, smp, mem, persistent, devices, bootDeviceIds, use, nics, vnc, - description, status, started, user, metrics); - } - } - - protected final ServerStatus status; - @Nullable - protected final Date started; - @Nullable - protected final String user; - protected final ServerMetrics metrics; - - public ServerInfo(String uuid, String name, int cpu, Integer smp, int mem, boolean persistent, - Map devices, Iterable bootDeviceIds, Iterable use, - Iterable nics, VNC vnc, String description, ServerStatus status, Date started, String user, - @Nullable ServerMetrics metrics) { - super(uuid, name, cpu, smp, mem, persistent, devices, bootDeviceIds, use, nics, vnc, description); - this.status = status; - this.started = started; - this.user = user; - this.metrics = metrics; - } - - /** - * - * @return active | stopped | paused | dumped | dead - */ - public ServerStatus getStatus() { - return status; - } - - // TODO undocumented - public Date getStarted() { - return started; - } - - /** - * - * @return metrics, if the server is running, or null - */ - @Nullable - public ServerMetrics getMetrics() { - return metrics; - } - - // TODO undocumented - /** - * - * @return owner of the server. - */ - public String getUser() { - return user; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((metrics == null) ? 0 : metrics.hashCode()); - result = prime * result + ((started == null) ? 0 : started.hashCode()); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - result = prime * result + ((user == null) ? 0 : user.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - ServerInfo other = (ServerInfo) obj; - if (metrics == null) { - if (other.metrics != null) - return false; - } else if (!metrics.equals(other.metrics)) - return false; - if (started == null) { - if (other.started != null) - return false; - } else if (!started.equals(other.started)) - return false; - if (status != other.status) - return false; - if (user == null) { - if (other.user != null) - return false; - } else if (!user.equals(other.user)) - return false; - return true; - } - - @Override - public String toString() { - return "[cpu=" + cpu + ", smp=" + smp + ", mem=" + mem + ", persistent=" + persistent + ", devices=" + devices - + ", bootDeviceIds=" + bootDeviceIds + ", nics=" + nics + ", vnc=" + vnc + ", uuid=" + uuid + ", name=" - + name + ", use=" + use + ", status=" + status + ", started=" + started + ", user=" + user + ", metrics=" - + metrics + "]"; - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerMetrics.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerMetrics.java deleted file mode 100644 index 8dd7f9b146..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerMetrics.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Map; - -import com.google.common.collect.ImmutableMap; - -/** - * - * @author Adrian Cole - */ -public class ServerMetrics { - - public static class Builder { - protected long txPackets; - protected long tx; - protected long rxPackets; - protected long rx; - protected Map driveMetrics = ImmutableMap. of(); - - public Builder txPackets(long txPackets) { - this.txPackets = txPackets; - return this; - } - - public Builder tx(long tx) { - this.tx = tx; - return this; - } - - public Builder rxPackets(long rxPackets) { - this.rxPackets = rxPackets; - return this; - } - - public Builder rx(long rx) { - this.rx = rx; - return this; - } - - public Builder driveMetrics(Map driveMetrics) { - this.driveMetrics = ImmutableMap.copyOf(checkNotNull(driveMetrics, "driveMetrics")); - return this; - } - - public ServerMetrics build() { - return new ServerMetrics(tx, txPackets, rx, rxPackets, driveMetrics); - } - } - - protected final long txPackets; - protected final long tx; - protected final long rxPackets; - protected final long rx; - protected final Map driveMetrics; - - public ServerMetrics(long tx, long txPackets, long rx, long rxPackets, Map driveMetrics) { - this.txPackets = txPackets; - this.tx = tx; - this.rxPackets = rxPackets; - this.rx = rx; - this.driveMetrics = ImmutableMap.copyOf(checkNotNull(driveMetrics, "driveMetrics")); - } - - // TODO undocumented - public long getTxPackets() { - return txPackets; - } - - // TODO undocumented - public long getTx() { - return tx; - } - - // TODO undocumented - public long getRxPackets() { - return rxPackets; - } - - // TODO undocumented - public long getRx() { - return rx; - } - - /** - * - * @return metrics keyed on device id ex. {@code ide:0:0} - */ - public Map getDriveMetrics() { - return driveMetrics; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((driveMetrics == null) ? 0 : driveMetrics.hashCode()); - result = prime * result + (int) (rx ^ (rx >>> 32)); - result = prime * result + (int) (rxPackets ^ (rxPackets >>> 32)); - result = prime * result + (int) (tx ^ (tx >>> 32)); - result = prime * result + (int) (txPackets ^ (txPackets >>> 32)); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ServerMetrics other = (ServerMetrics) obj; - if (driveMetrics == null) { - if (other.driveMetrics != null) - return false; - } else if (!driveMetrics.equals(other.driveMetrics)) - return false; - if (rx != other.rx) - return false; - if (rxPackets != other.rxPackets) - return false; - if (tx != other.tx) - return false; - if (txPackets != other.txPackets) - return false; - return true; - } - - @Override - public String toString() { - return "[ txPackets=" + txPackets + ", tx=" + tx + ", rxPackets=" + rxPackets + ", rx=" + rx + ", driveMetrics=" - + driveMetrics + "]"; - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerStatus.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerStatus.java deleted file mode 100644 index 5efaecd68c..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerStatus.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * - * @author Adrian Cole - */ -public enum ServerStatus { - ACTIVE, STOPPED, PAUSED, DUMPED, DEAD, UNRECOGNIZED; - public String value() { - return name().toLowerCase(); - } - - @Override - public String toString() { - return value(); - } - - public static ServerStatus fromValue(String status) { - try { - return valueOf(checkNotNull(status, "status").toUpperCase()); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/StaticIPInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/StaticIPInfo.java deleted file mode 100644 index a50f735572..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/StaticIPInfo.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -public class StaticIPInfo { - public static class Builder { - protected String ip; - protected String user; - protected String netmask; - protected Set nameservers = ImmutableSet.of(); - protected String gateway; - - public Builder ip(String ip) { - this.ip = ip; - return this; - } - - public Builder user(String user) { - this.user = user; - return this; - } - - public Builder nameservers(Iterable nameservers) { - this.nameservers = ImmutableSet.copyOf(checkNotNull(nameservers, "nameservers")); - return this; - } - - public Builder gateway(String gateway) { - this.gateway = gateway; - return this; - } - - public Builder netmask(String netmask) { - this.netmask = netmask; - return this; - } - - public StaticIPInfo build() { - return new StaticIPInfo(ip, user, netmask, nameservers, gateway); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((gateway == null) ? 0 : gateway.hashCode()); - result = prime * result + ((nameservers == null) ? 0 : nameservers.hashCode()); - result = prime * result + ((netmask == null) ? 0 : netmask.hashCode()); - result = prime * result + ((user == null) ? 0 : user.hashCode()); - result = prime * result + ((ip == null) ? 0 : ip.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Builder other = (Builder) obj; - if (gateway == null) { - if (other.gateway != null) - return false; - } else if (!gateway.equals(other.gateway)) - return false; - if (nameservers == null) { - if (other.nameservers != null) - return false; - } else if (!nameservers.equals(other.nameservers)) - return false; - if (netmask == null) { - if (other.netmask != null) - return false; - } else if (!netmask.equals(other.netmask)) - return false; - if (user == null) { - if (other.user != null) - return false; - } else if (!user.equals(other.user)) - return false; - if (ip == null) { - if (other.ip != null) - return false; - } else if (!ip.equals(other.ip)) - return false; - return true; - } - } - - protected final String ip; - protected final String user; - protected final String netmask; - protected final Set nameservers; - protected final String gateway; - - public StaticIPInfo(String ip, String user, String netmask, Iterable nameservers, String gateway) { - this.ip = checkNotNull(ip, "ip"); - this.user = checkNotNull(user, "user"); - this.netmask = checkNotNull(netmask, "netmask"); - this.nameservers = ImmutableSet.copyOf(checkNotNull(nameservers, "nameservers")); - this.gateway = checkNotNull(gateway, "gateway"); - } - - /** - * - * @return ip of the ip. - */ - @Nullable - public String getAddress() { - return ip; - } - - /** - * - * @return user owning the ip - */ - public String getUser() { - return user; - } - - /** - * - * @return netmask of the ip - */ - public String getNetmask() { - return netmask; - } - - /** - * - * @return nameservers of the ip - */ - public Set getNameservers() { - return nameservers; - } - - /** - * - * @return gateway of the ip - */ - public String getGateway() { - return gateway; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((gateway == null) ? 0 : gateway.hashCode()); - result = prime * result + ((nameservers == null) ? 0 : nameservers.hashCode()); - result = prime * result + ((netmask == null) ? 0 : netmask.hashCode()); - result = prime * result + ((user == null) ? 0 : user.hashCode()); - result = prime * result + ((ip == null) ? 0 : ip.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - StaticIPInfo other = (StaticIPInfo) obj; - if (gateway == null) { - if (other.gateway != null) - return false; - } else if (!gateway.equals(other.gateway)) - return false; - if (nameservers == null) { - if (other.nameservers != null) - return false; - } else if (!nameservers.equals(other.nameservers)) - return false; - if (netmask == null) { - if (other.netmask != null) - return false; - } else if (!netmask.equals(other.netmask)) - return false; - if (user == null) { - if (other.user != null) - return false; - } else if (!user.equals(other.user)) - return false; - if (ip == null) { - if (other.ip != null) - return false; - } else if (!ip.equals(other.ip)) - return false; - return true; - } - - @Override - public String toString() { - return "[ip=" + ip + ", user=" + user + ", netmask=" + netmask + ", nameservers=" - + nameservers + ", gateway=" + gateway + "]"; - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/VLANInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/VLANInfo.java deleted file mode 100644 index 57dc84d82f..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/VLANInfo.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.javax.annotation.Nullable; - -/** - * - * @author Adrian Cole - */ -public class VLANInfo { - public static class Builder { - protected String uuid; - protected String name; - protected String user; - - public Builder uuid(String uuid) { - this.uuid = uuid; - return this; - } - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder user(String user) { - this.user = user; - return this; - } - - public VLANInfo build() { - return new VLANInfo(uuid, name, user); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((user == null) ? 0 : user.hashCode()); - result = prime * result + ((uuid == null) ? 0 : uuid.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Builder other = (Builder) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (user == null) { - if (other.user != null) - return false; - } else if (!user.equals(other.user)) - return false; - if (uuid == null) { - if (other.uuid != null) - return false; - } else if (!uuid.equals(other.uuid)) - return false; - return true; - } - } - - @Nullable - protected final String uuid; - protected final String name; - protected final String user; - - public VLANInfo(String uuid, String name, String user) { - this.uuid = checkNotNull(uuid, "uuid"); - this.name = checkNotNull(name, "name"); - this.user = checkNotNull(user, "user"); - } - - /** - * - * @return uuid of the vlan. - */ - @Nullable - public String getUuid() { - return uuid; - } - - /** - * - * @return name of the vlan - */ - public String getName() { - return name; - } - - /** - * - * @return user owning the vlan - */ - public String getUser() { - return user; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((user == null) ? 0 : user.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - VLANInfo other = (VLANInfo) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (user == null) { - if (other.user != null) - return false; - } else if (!user.equals(other.user)) - return false; - - return true; - } - - @Override - public String toString() { - return "[uuid=" + uuid + ", name=" + name + ", user=" + user + "]"; - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/VNC.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/VNC.java deleted file mode 100644 index 0c455db0dd..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/VNC.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.domain; - -import org.jclouds.javax.annotation.Nullable; - -/** - * - * @author Adrian Cole - */ -public class VNC { - @Nullable - private final String ip; - @Nullable - private final String password; - private final boolean tls; - - public VNC(String ip, String password, boolean tls) { - this.ip = ip; - this.password = password; - this.tls = tls; - } - - /** - * - * @return IP address for overlay VNC access on port 5900. Set to 'auto', to reuse nic:0:dhcp if - * available, or otherwise allocate a temporary IP at boot. - */ - public String getIp() { - return ip; - } - - /** - * - * @return Password for VNC access. If unset, VNC is disabled. - */ - public String getPassword() { - return password; - } - - /** - * - * @return Set to 'on' to require VeNCrypt-style TLS auth in addition to the password. If this is - * unset, only unencrypted VNC is available. - */ - public boolean isTls() { - return tls; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((ip == null) ? 0 : ip.hashCode()); - result = prime * result + ((password == null) ? 0 : password.hashCode()); - result = prime * result + (tls ? 1231 : 1237); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - VNC other = (VNC) obj; - if (ip == null) { - if (other.ip != null) - return false; - } else if (!ip.equals(other.ip)) - return false; - if (password == null) { - if (other.password != null) - return false; - } else if (!password.equals(other.password)) - return false; - if (tls != other.tls) - return false; - return true; - } - - @Override - public String toString() { - return "[ip=" + ip + ", password=" + password + ", tls=" + tls + "]"; - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/BaseDriveToMap.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/BaseDriveToMap.java deleted file mode 100644 index 8405cdc4c9..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/BaseDriveToMap.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Map; - -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.ClaimType; -import org.jclouds.cloudsigma.domain.Drive; - -import com.google.common.base.Function; -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableMap; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class BaseDriveToMap implements Function> { - @Override - public Map apply(Drive from) { - checkNotNull(from, "drive"); - ImmutableMap.Builder builder = ImmutableMap.builder(); - builder.put("name", from.getName()); - builder.put("size", from.getSize() + ""); - if (from.getClaimType() != ClaimType.EXCLUSIVE) - builder.put("claim:type", from.getClaimType().toString()); - if (from.getTags().size() != 0) - builder.put("tags", Joiner.on(' ').join(from.getTags())); - if (from.getReaders().size() != 0) - builder.put("readers", Joiner.on(' ').join(from.getReaders())); - if (from.getUse().size() != 0) - builder.put("use", Joiner.on(' ').join(from.getUse())); - return builder.build(); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/DriveDataToMap.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/DriveDataToMap.java deleted file mode 100644 index 292d3ccc09..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/DriveDataToMap.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Predicates.equalTo; -import static com.google.common.base.Predicates.not; -import static com.google.common.collect.Maps.filterKeys; - -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.DriveData; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class DriveDataToMap implements Function> { - private final BaseDriveToMap baseDriveToMap; - - @Inject - public DriveDataToMap(BaseDriveToMap baseDriveToMap) { - this.baseDriveToMap = baseDriveToMap; - } - - @Override - public Map apply(DriveData from) { - return renameKey(baseDriveToMap.apply(from), "use", "use"); - } - - /** - * If the supplied map contains the key {@code k1}, its value will be assigned to the key {@code - * k2}. Note that this doesn't modify the input map. - * - * @param - * type of value the map holds - * @param in - * the map you wish to make a copy of - * @param k1 - * old key - * @param k2 - * new key - * @return copy of the map with the value of the key re-routed, or the original, if it {@code k1} - * wasn't present. - */ - @VisibleForTesting - static Map renameKey(Map in, String k1, String k2) { - if (checkNotNull(in, "input map").containsKey(checkNotNull(k1, "old key"))) { - Builder builder = ImmutableMap.builder(); - builder.putAll(filterKeys(in, not(equalTo(k1)))); - V tags = in.get(k1); - builder.put(checkNotNull(k2, "new key"), tags); - in = builder.build(); - } - return in; - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToDriveInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToDriveInfo.java deleted file mode 100644 index 14c3181a82..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToDriveInfo.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.DriveInfo; -import org.jclouds.http.HttpResponse; - -import com.google.common.base.Function; -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class KeyValuesDelimitedByBlankLinesToDriveInfo implements Function { - private final ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet setParser; - - @Inject - public KeyValuesDelimitedByBlankLinesToDriveInfo(ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet setParser) { - this.setParser = setParser; - } - - @Override - public DriveInfo apply(HttpResponse response) { - Set drives = setParser.apply(response); - if (drives.size() == 0) - return null; - return Iterables.get(drives, 0); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToProfileInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToProfileInfo.java deleted file mode 100644 index 89f9637761..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToProfileInfo.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.ProfileInfo; -import org.jclouds.http.HttpResponse; - -import com.google.common.base.Function; -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class KeyValuesDelimitedByBlankLinesToProfileInfo implements Function { - private final ListOfKeyValuesDelimitedByBlankLinesToProfileInfoSet setParser; - - @Inject - public KeyValuesDelimitedByBlankLinesToProfileInfo(ListOfKeyValuesDelimitedByBlankLinesToProfileInfoSet setParser) { - this.setParser = setParser; - } - - @Override - public ProfileInfo apply(HttpResponse response) { - Set drives = setParser.apply(response); - if (drives.size() == 0) - return null; - return Iterables.get(drives, 0); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToServerInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToServerInfo.java deleted file mode 100644 index 7fb1c1844c..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToServerInfo.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.ServerInfo; -import org.jclouds.http.HttpResponse; - -import com.google.common.base.Function; -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class KeyValuesDelimitedByBlankLinesToServerInfo implements Function { - private final ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet setParser; - - @Inject - public KeyValuesDelimitedByBlankLinesToServerInfo(ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet setParser) { - this.setParser = setParser; - } - - @Override - public ServerInfo apply(HttpResponse response) { - Set drives = setParser.apply(response); - if (drives.size() == 0) - return null; - return Iterables.get(drives, 0); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToStaticIPInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToStaticIPInfo.java deleted file mode 100644 index c4008ccc94..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToStaticIPInfo.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.StaticIPInfo; -import org.jclouds.http.HttpResponse; - -import com.google.common.base.Function; -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class KeyValuesDelimitedByBlankLinesToStaticIPInfo implements Function { - private final ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet setParser; - - @Inject - public KeyValuesDelimitedByBlankLinesToStaticIPInfo(ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet setParser) { - this.setParser = setParser; - } - - @Override - public StaticIPInfo apply(HttpResponse response) { - Set drives = setParser.apply(response); - if (drives.size() == 0) - return null; - return Iterables.get(drives, 0); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToVLANInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToVLANInfo.java deleted file mode 100644 index 4887b9029b..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToVLANInfo.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.VLANInfo; -import org.jclouds.http.HttpResponse; - -import com.google.common.base.Function; -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class KeyValuesDelimitedByBlankLinesToVLANInfo implements Function { - private final ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet setParser; - - @Inject - public KeyValuesDelimitedByBlankLinesToVLANInfo(ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet setParser) { - this.setParser = setParser; - } - - @Override - public VLANInfo apply(HttpResponse response) { - Set drives = setParser.apply(response); - if (drives.size() == 0) - return null; - return Iterables.get(drives, 0); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.java deleted file mode 100644 index 333245df91..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.DriveInfo; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ReturnStringIf2xx; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet implements Function> { - private final ReturnStringIf2xx returnStringIf200; - private final ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter; - private final MapToDriveInfo mapToDrive; - - @Inject - ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet(ReturnStringIf2xx returnStringIf200, - ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter, MapToDriveInfo mapToDrive) { - this.returnStringIf200 = returnStringIf200; - this.mapConverter = mapConverter; - this.mapToDrive = mapToDrive; - } - - @Override - public Set apply(HttpResponse response) { - String text = returnStringIf200.apply(response); - if (text == null || text.trim().equals("")) - return ImmutableSet. of(); - return ImmutableSet.copyOf(Iterables.transform(mapConverter.apply(text), mapToDrive)); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToListOfMaps.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToListOfMaps.java deleted file mode 100644 index c829b3668a..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToListOfMaps.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.List; -import java.util.Map; - -import javax.inject.Singleton; - -import com.google.common.base.Function; -import com.google.common.base.Splitter; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class ListOfKeyValuesDelimitedByBlankLinesToListOfMaps implements Function>> { - - @Override - public List> apply(String from) { - List> maps = Lists.newArrayList(); - for (String listOfKeyValues : Splitter.on("\n\n").split(from)) { - if (!"".equals(listOfKeyValues)) { - Map map = Maps.newLinkedHashMap(); - for (String keyValueLine : Splitter.on('\n').split(listOfKeyValues)) { - if (!"".equals(keyValueLine)) { - int firstIndex = keyValueLine.indexOf(' '); - if (firstIndex != -1) { - String key = keyValueLine.substring(0, firstIndex); - String value = keyValueLine.substring(firstIndex + 1).replace("\\n", "\n"); - map.put(key, value); - } - } - } - if (map.size() != 0) - maps.add(map); - } - } - return maps; - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToProfileInfoSet.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToProfileInfoSet.java deleted file mode 100644 index b010d00a0e..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToProfileInfoSet.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.ProfileInfo; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ReturnStringIf2xx; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class ListOfKeyValuesDelimitedByBlankLinesToProfileInfoSet implements Function> { - private final ReturnStringIf2xx returnStringIf200; - private final ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter; - private final MapToProfileInfo mapToProfile; - - @Inject - ListOfKeyValuesDelimitedByBlankLinesToProfileInfoSet(ReturnStringIf2xx returnStringIf200, - ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter, MapToProfileInfo mapToProfile) { - this.returnStringIf200 = returnStringIf200; - this.mapConverter = mapConverter; - this.mapToProfile = mapToProfile; - } - - @Override - public Set apply(HttpResponse response) { - String text = returnStringIf200.apply(response); - if (text == null || text.trim().equals("")) - return ImmutableSet. of(); - return ImmutableSet.copyOf(Iterables.transform(mapConverter.apply(text), mapToProfile)); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.java deleted file mode 100644 index 785c57f638..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.ServerInfo; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ReturnStringIf2xx; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - - -/** - * - * @author Adrian Cole - */ -@Singleton -public class ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet implements Function> { - private final ReturnStringIf2xx returnStringIf200; - private final ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter; - private final MapToServerInfo mapToServer; - - @Inject - ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet(ReturnStringIf2xx returnStringIf200, - ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter, MapToServerInfo mapToServer) { - this.returnStringIf200 = returnStringIf200; - this.mapConverter = mapConverter; - this.mapToServer = mapToServer; - } - - @Override - public Set apply(HttpResponse response) { - String text = returnStringIf200.apply(response); - if (text == null || text.trim().equals("")) - return ImmutableSet. of(); - return ImmutableSet.copyOf(Iterables.transform(mapConverter.apply(text), mapToServer)); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet.java deleted file mode 100644 index a52c142305..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.StaticIPInfo; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ReturnStringIf2xx; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet implements Function> { - private final ReturnStringIf2xx returnStringIf200; - private final ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter; - private final MapToStaticIPInfo mapToProfile; - - @Inject - ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet(ReturnStringIf2xx returnStringIf200, - ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter, MapToStaticIPInfo mapToProfile) { - this.returnStringIf200 = returnStringIf200; - this.mapConverter = mapConverter; - this.mapToProfile = mapToProfile; - } - - @Override - public Set apply(HttpResponse response) { - String text = returnStringIf200.apply(response); - if (text == null || text.trim().equals("")) - return ImmutableSet. of(); - return ImmutableSet.copyOf(Iterables.transform(mapConverter.apply(text), mapToProfile)); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.java deleted file mode 100644 index 3b4148414e..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.VLANInfo; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ReturnStringIf2xx; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet implements Function> { - private final ReturnStringIf2xx returnStringIf200; - private final ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter; - private final MapToVLANInfo mapToProfile; - - @Inject - ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet(ReturnStringIf2xx returnStringIf200, - ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter, MapToVLANInfo mapToProfile) { - this.returnStringIf200 = returnStringIf200; - this.mapConverter = mapConverter; - this.mapToProfile = mapToProfile; - } - - @Override - public Set apply(HttpResponse response) { - String text = returnStringIf200.apply(response); - if (text == null || text.trim().equals("")) - return ImmutableSet. of(); - return ImmutableSet.copyOf(Iterables.transform(mapConverter.apply(text), mapToProfile)); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfMapsToListOfKeyValuesDelimitedByBlankLines.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfMapsToListOfKeyValuesDelimitedByBlankLines.java deleted file mode 100644 index e05a9216eb..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ListOfMapsToListOfKeyValuesDelimitedByBlankLines.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.Map; - -import javax.inject.Singleton; - -import com.google.common.base.Function; -import com.google.common.base.Joiner; -import com.google.common.collect.Iterables; -import com.google.common.collect.Maps; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class ListOfMapsToListOfKeyValuesDelimitedByBlankLines implements - Function>, String> { - - @Override - public String apply(Iterable> from) { - return Joiner.on("\n\n").join(Iterables.transform(from, new Function, String>() { - - @Override - public String apply(Map from) { - return Joiner.on('\n').withKeyValueSeparator(" ") - .join(Maps.transformValues(from, new Function() { - - @Override - public String apply(String from) { - return from.replace("\n", "\\n"); - } - - })); - } - - })); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java deleted file mode 100644 index 40ffb0c659..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.BlockDevice; -import org.jclouds.cloudsigma.domain.Device; -import org.jclouds.cloudsigma.domain.IDEDevice; -import org.jclouds.cloudsigma.domain.MediaType; -import org.jclouds.cloudsigma.domain.SCSIDevice; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.common.collect.Maps; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class MapToDevices implements Function, Map> { - @Singleton - public static class DeviceToId implements Function { - @Override - public String apply(Device input) { - return input.getId(); - } - } - - private final Function deviceToId; - - @Inject - public MapToDevices(Function deviceToId) { - this.deviceToId = deviceToId; - } - - public Map apply(Map from) { - Builder devices = ImmutableSet.builder(); - addIDEDevices(from, devices); - addSCSIDevices(from, devices); - addBlockDevices(from, devices); - - return Maps.uniqueIndex(devices.build(), deviceToId); - } - - protected void addBlockDevices(Map from, Builder devices) { - BLOCK: for (int index : new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }) { - String key = String.format("block:0:%d", index); - if (!from.containsKey(key)) - break BLOCK; - devices.add(populateBuilder(new BlockDevice.Builder(index), key, from).build()); - } - } - - protected void addSCSIDevices(Map from, Builder devices) { - SCSI: for (int unit : new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }) { - String key = String.format("scsi:0:%d", unit); - if (!from.containsKey(key)) - break SCSI; - devices.add(populateBuilder(new SCSIDevice.Builder(unit), key, from).build()); - } - } - - protected void addIDEDevices(Map from, Builder devices) { - IDE: for (int bus : new int[] { 0, 1 }) - for (int unit : new int[] { 0, 1 }) { - String key = String.format("ide:%d:%d", bus, unit); - if (!from.containsKey(key)) - break IDE; - devices.add(populateBuilder(new IDEDevice.Builder(bus, unit), key, from).build()); - } - } - - protected Device.Builder populateBuilder(Device.Builder deviceBuilder, String key, Map from) { - deviceBuilder.uuid(from.get(key)); - if (from.containsKey(key + ":media")) - deviceBuilder.mediaType(MediaType.fromValue(from.get(key + ":media"))); - return deviceBuilder; - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveInfo.java deleted file mode 100644 index 24a471d71a..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveInfo.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.net.URI; -import java.util.Map; -import java.util.Map.Entry; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.ClaimType; -import org.jclouds.cloudsigma.domain.DriveInfo; -import org.jclouds.cloudsigma.domain.DriveMetrics; -import org.jclouds.cloudsigma.domain.DriveStatus; -import org.jclouds.cloudsigma.domain.DriveType; -import org.jclouds.logging.Logger; - -import com.google.common.base.Function; -import com.google.common.base.Splitter; -import com.google.common.collect.Maps; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class MapToDriveInfo implements Function, DriveInfo> { - - @Resource - protected Logger logger = Logger.NULL; - - @Override - public DriveInfo apply(Map from) { - if (from.size() == 0) - return null; - DriveInfo.Builder builder = new DriveInfo.Builder(); - builder.name(from.get("name")); - if (from.containsKey("use")) - builder.use(Splitter.on(' ').split(from.get("use"))); - if (from.containsKey("status")) - builder.status(DriveStatus.fromValue(from.get("status"))); - builder.metrics(buildMetrics(from)); - builder.user(from.get("user")); - builder.encryptionCipher(from.get("encryption:cipher")); - builder.uuid(from.get("drive")); - if (from.containsKey("claim:type")) - builder.claimType(ClaimType.fromValue(from.get("claim:type"))); - if (from.containsKey("claimed")) - builder.claimed(Splitter.on(' ').split(from.get("claimed"))); - if (from.containsKey("tags")) - builder.tags(Splitter.on(' ').split(from.get("tags"))); - if (from.containsKey("readers")) - builder.readers(Splitter.on(' ').split(from.get("readers"))); - if (from.containsKey("size")) - builder.size(Long.valueOf(from.get("size"))); - Map metadata = Maps.newLinkedHashMap(); - for (Entry entry : from.entrySet()) { - if (entry.getKey().startsWith("user:")) - metadata.put(entry.getKey().substring(entry.getKey().indexOf(':') + 1), entry.getValue()); - } - if (from.containsKey("use")) - builder.use(Splitter.on(' ').split(from.get("use"))); - if (from.containsKey("bits")) - builder.bits(Integer.valueOf(from.get("bits"))); - if (from.containsKey("url")) - builder.url(URI.create(from.get("url"))); - builder.encryptionKey(from.get("encryption:key")); - builder.description(from.get("description")); - builder.installNotes(from.get("install_notes")); - builder.os(from.get("os")); - if (from.containsKey("drive_type")) - builder.driveType(Splitter.on(',').split(from.get("drive_type"))); - if (from.containsKey("autoexpanding")) - builder.autoexpanding(Boolean.valueOf(from.get("autoexpanding"))); - if (from.containsKey("free")) - builder.free(Boolean.valueOf(from.get("free"))); - if (from.containsKey("type")) - builder.type(DriveType.fromValue(from.get("type"))); - try { - return builder.build(); - } catch (NullPointerException e) { - logger.trace("entry missing data: %s; %s", e.getMessage(), from); - return null; - } - } - - protected DriveMetrics buildMetrics(Map from) { - DriveMetrics.Builder metricsBuilder = new DriveMetrics.Builder(); - if (from.containsKey("read:bytes")) - metricsBuilder.readBytes(Long.valueOf(from.get("read:bytes"))); - if (from.containsKey("read:requests")) - metricsBuilder.readRequests(Long.valueOf(from.get("read:requests"))); - if (from.containsKey("write:bytes")) - metricsBuilder.writeBytes(Long.valueOf(from.get("write:bytes"))); - if (from.containsKey("write:requests")) - metricsBuilder.writeRequests(Long.valueOf(from.get("write:requests"))); - return metricsBuilder.build(); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveMetrics.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveMetrics.java deleted file mode 100644 index 260d69797a..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDriveMetrics.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.Map; - -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.DriveMetrics; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class MapToDriveMetrics implements Function, Map> { - - public Map apply(Map from) { - Builder builder = ImmutableMap.builder(); - addIDEDevices(from, builder); - addSCSIDevices(from, builder); - addBlockDevices(from, builder); - return builder.build(); - } - - protected void addBlockDevices(Map from, Builder devices) { - BLOCK: for (int index : new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }) { - String key = String.format("block:0:%d", index); - if (!from.containsKey(key)) - break BLOCK; - devices.put(key, buildMetrics(key, from)); - } - } - - protected void addSCSIDevices(Map from, Builder devices) { - SCSI: for (int unit : new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }) { - String key = String.format("scsi:0:%d", unit); - if (!from.containsKey(key)) - break SCSI; - devices.put(key, buildMetrics(key, from)); - } - } - - protected void addIDEDevices(Map from, Builder devices) { - IDE: for (int bus : new int[] { 0, 1 }) - for (int unit : new int[] { 0, 1 }) { - String key = String.format("ide:%d:%d", bus, unit); - if (!from.containsKey(key)) - break IDE; - devices.put(key, buildMetrics(key, from)); - } - } - - protected DriveMetrics buildMetrics(String key, Map from) { - DriveMetrics.Builder builder = new DriveMetrics.Builder(); - if (from.containsKey(key + ":read:bytes")) - builder.readBytes(Long.valueOf(from.get(key + ":read:bytes"))); - if (from.containsKey(key + ":read:requests")) - builder.readRequests(Long.valueOf(from.get(key + ":read:requests"))); - if (from.containsKey(key + ":write:bytes")) - builder.writeBytes(Long.valueOf(from.get(key + ":write:bytes"))); - if (from.containsKey(key + ":write:requests")) - builder.writeRequests(Long.valueOf(from.get(key + ":write:requests"))); - return builder.build(); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToNICs.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToNICs.java deleted file mode 100644 index d8c3a84cae..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToNICs.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.List; -import java.util.Map; - -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.Model; -import org.jclouds.cloudsigma.domain.NIC; - -import com.google.common.base.Function; -import com.google.common.base.Splitter; -import com.google.common.collect.ImmutableList; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class MapToNICs implements Function, List> { - - @Override - public List apply(Map from) { - ImmutableList.Builder nics = ImmutableList.builder(); - NIC: for (int id : new int[] { 0, 1 }) { - String key = String.format("nic:%d", id); - if (!from.containsKey(key + ":model")) - break NIC; - NIC.Builder nicBuilder = new NIC.Builder(); - nicBuilder.dhcp(from.get(key + ":dhcp")); - nicBuilder.model(Model.fromValue(from.get(key + ":model"))); - nicBuilder.vlan(from.get(key + ":vlan")); - nicBuilder.mac(from.get(key + ":mac")); - if (from.containsKey(key + ":block")) - nicBuilder.block(Splitter.on(' ').split(from.get(key + ":block"))); - nics.add(nicBuilder.build()); - } - return nics.build(); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToProfileInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToProfileInfo.java deleted file mode 100644 index f19ac709f3..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToProfileInfo.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.Map; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.ProfileInfo; -import org.jclouds.cloudsigma.domain.ProfileType; -import org.jclouds.logging.Logger; - -import com.google.common.base.Function; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class MapToProfileInfo implements Function, ProfileInfo> { - - @Resource - protected Logger logger = Logger.NULL; - - @Override - public ProfileInfo apply(Map from) { - if (from.size() == 0) - return null; - if (from.size() == 0) - return null; - ProfileInfo.Builder builder = new ProfileInfo.Builder(); - builder.uuid(from.get("uuid")); - builder.email(from.get("email")); - builder.firstName(from.get("first_name")); - builder.lastName(from.get("last_name")); - builder.nickName(from.get("nick_name")); - builder.type(ProfileType.fromValue(from.get("type"))); - try { - return builder.build(); - } catch (NullPointerException e) { - logger.trace("entry missing data: %s; %s", e.getMessage(), from); - return null; - } - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToServerInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToServerInfo.java deleted file mode 100644 index 533b3ce024..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToServerInfo.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.Device; -import org.jclouds.cloudsigma.domain.NIC; -import org.jclouds.cloudsigma.domain.ServerInfo; -import org.jclouds.cloudsigma.domain.ServerMetrics; -import org.jclouds.cloudsigma.domain.ServerStatus; -import org.jclouds.cloudsigma.domain.VNC; - -import com.google.common.base.Function; -import com.google.common.base.Splitter; -import com.google.common.collect.Maps; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class MapToServerInfo implements Function, ServerInfo> { - private final Function, Map> mapToDevices; - private final Function, ServerMetrics> mapToMetrics; - private final Function, List> mapToNICs; - - @Inject - public MapToServerInfo(Function, Map> mapToDevices, - Function, ServerMetrics> mapToMetrics, Function, List> mapToNICs) { - this.mapToDevices = mapToDevices; - this.mapToMetrics = mapToMetrics; - this.mapToNICs = mapToNICs; - } - - @Override - public ServerInfo apply(Map from) { - if (from.size() == 0) - return null; - ServerInfo.Builder builder = new ServerInfo.Builder(); - builder.name(from.get("name")); - builder.description(from.get("description")); - builder.persistent(Boolean.parseBoolean(from.get("persistent"))); - if (from.containsKey("use")) - builder.use(Splitter.on(' ').split(from.get("use"))); - if (from.containsKey("status")) - builder.status(ServerStatus.fromValue(from.get("status"))); - if (from.containsKey("smp") && !"auto".equals(from.get("smp"))) - builder.smp(Integer.valueOf(from.get("smp"))); - builder.cpu(Integer.parseInt(from.get("cpu"))); - builder.mem(Integer.parseInt(from.get("mem"))); - builder.user(from.get("user")); - if (from.containsKey("started")) - builder.started(new Date(Long.valueOf(from.get("started")))); - builder.uuid(from.get("server")); - builder.vnc(new VNC(from.get("vnc:ip"), from.get("vnc:password"), from.containsKey("vnc:tls") - && Boolean.valueOf(from.get("vnc:tls")))); - if (from.containsKey("boot")) - builder.bootDeviceIds(Splitter.on(' ').split(from.get("boot"))); - - Map metadata = Maps.newLinkedHashMap(); - for (Entry entry : from.entrySet()) { - if (entry.getKey().startsWith("user:")) - metadata.put(entry.getKey().substring(entry.getKey().indexOf(':') + 1), entry.getValue()); - } - builder.nics(mapToNICs.apply(from)); - builder.devices(mapToDevices.apply(from)); - builder.metrics(mapToMetrics.apply(from)); - return builder.build(); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToServerMetrics.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToServerMetrics.java deleted file mode 100644 index 9cac5fbf9f..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToServerMetrics.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.DriveMetrics; -import org.jclouds.cloudsigma.domain.ServerMetrics; - -import com.google.common.base.Function; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class MapToServerMetrics implements Function, ServerMetrics> { - private final Function, Map> mapToDriveMetrics; - - @Inject - public MapToServerMetrics(Function, Map> mapToDriveMetrics) { - this.mapToDriveMetrics = mapToDriveMetrics; - } - - public ServerMetrics apply(Map from) { - ServerMetrics.Builder metricsBuilder = new ServerMetrics.Builder(); - if (from.containsKey("tx:packets")) - metricsBuilder.txPackets(Long.valueOf(from.get("tx:packets"))); - if (from.containsKey("tx")) - metricsBuilder.tx(Long.valueOf(from.get("tx"))); - if (from.containsKey("rx:packets")) - metricsBuilder.rxPackets(Long.valueOf(from.get("rx:packets"))); - if (from.containsKey("rx")) - metricsBuilder.rx(Long.valueOf(from.get("rx"))); - metricsBuilder.driveMetrics(mapToDriveMetrics.apply(from)); - - ServerMetrics metrics = metricsBuilder.build(); - return metrics; - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToStaticIPInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToStaticIPInfo.java deleted file mode 100644 index ea4a1396a0..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToStaticIPInfo.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.Map; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.StaticIPInfo; -import org.jclouds.logging.Logger; - -import com.google.common.base.Function; -import com.google.common.base.Splitter; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class MapToStaticIPInfo implements Function, StaticIPInfo> { - - @Resource - protected Logger logger = Logger.NULL; - - @Override - public StaticIPInfo apply(Map from) { - if (from.size() == 0) - return null; - if (from.size() == 0) - return null; - StaticIPInfo.Builder builder = new StaticIPInfo.Builder(); - builder.ip(from.get("resource")); - builder.user(from.get("user")); - builder.netmask(from.get("netmask")); - builder.nameservers(Splitter.on(' ').split(from.get("nameserver"))); - builder.gateway(from.get("gateway")); - - try { - return builder.build(); - } catch (NullPointerException e) { - logger.trace("entry missing data: %s; %s", e.getMessage(), from); - return null; - } - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToVLANInfo.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToVLANInfo.java deleted file mode 100644 index 6adc666994..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToVLANInfo.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.Map; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.VLANInfo; -import org.jclouds.logging.Logger; - -import com.google.common.base.Function; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class MapToVLANInfo implements Function, VLANInfo> { - - @Resource - protected Logger logger = Logger.NULL; - - @Override - public VLANInfo apply(Map from) { - if (from.size() == 0) - return null; - if (from.size() == 0) - return null; - VLANInfo.Builder builder = new VLANInfo.Builder(); - builder.uuid(from.get("resource")); - builder.name(from.get("name")); - builder.user(from.get("user")); - try { - return builder.build(); - } catch (NullPointerException e) { - logger.trace("entry missing data: %s; %s", e.getMessage(), from); - return null; - } - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ReturnPayload.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ReturnPayload.java deleted file mode 100644 index e353279856..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ReturnPayload.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpResponse; -import org.jclouds.io.Payload; - -import com.google.common.base.Function; - -/** - * @author Adrian Cole - */ -@Singleton -public class ReturnPayload implements Function { - - public Payload apply(HttpResponse from) { - return from.getPayload(); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ServerToMap.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ServerToMap.java deleted file mode 100644 index 38daffa989..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/ServerToMap.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Map; -import java.util.Map.Entry; - -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.domain.Device; -import org.jclouds.cloudsigma.domain.NIC; -import org.jclouds.cloudsigma.domain.Server; - -import com.google.common.base.Function; -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableMap; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class ServerToMap implements Function> { - @Override - public Map apply(Server from) { - checkNotNull(from, "server"); - ImmutableMap.Builder builder = ImmutableMap.builder(); - builder.put("name", from.getName()); - builder.put("cpu", from.getCpu() + ""); - if (from.getSmp() != null) - builder.put("smp", from.getSmp() + ""); - else - builder.put("smp", "auto"); - builder.put("mem", from.getMem() + ""); - builder.put("persistent", from.isPersistent() + ""); - if (from.getBootDeviceIds().size() != 0) - builder.put("boot", Joiner.on(' ').join(from.getBootDeviceIds())); - for (Entry entry : from.getDevices().entrySet()) { - builder.put(entry.getKey(), entry.getValue().getDriveUuid()); - builder.put(entry.getKey() + ":media", entry.getValue().getMediaType().toString()); - } - int nicId = 0; - for (NIC nic : from.getNics()) { - builder.put("nic:" + nicId + ":model", nic.getModel().toString()); - if (nic.getDhcp() != null) - builder.put("nic:" + nicId + ":dhcp", nic.getDhcp()); - if (nic.getVlan() != null) - builder.put("nic:" + nicId + ":vlan", nic.getVlan()); - if (nic.getMac() != null) - builder.put("nic:" + nicId + ":mac", nic.getMac()); - nicId++; - } - builder.put("vnc:ip", from.getVnc().getIp() == null ? "auto" : from.getVnc().getIp()); - if (from.getVnc().getPassword() != null) - builder.put("vnc:password", from.getVnc().getPassword()); - if (from.getVnc().isTls()) - builder.put("vnc:tls", "on"); - if (from.getUse().size() != 0) - builder.put("use", Joiner.on(' ').join(from.getUse())); - return builder.build(); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlines.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlines.java deleted file mode 100644 index 10d0ac3629..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlines.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static com.google.common.collect.Sets.newTreeSet; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ReturnStringIf2xx; - -import com.google.common.base.Function; -import com.google.common.base.Splitter; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class SplitNewlines implements Function> { - private final ReturnStringIf2xx returnStringIf200; - - @Inject - protected SplitNewlines(ReturnStringIf2xx returnStringIf200) { - this.returnStringIf200 = returnStringIf200; - } - - @Override - public Set apply(HttpResponse response) { - return newTreeSet(Splitter.on('\n').omitEmptyStrings().split(returnStringIf200.apply(response))); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlinesAndReturnSecondField.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlinesAndReturnSecondField.java deleted file mode 100644 index 36d504c791..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/SplitNewlinesAndReturnSecondField.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ReturnStringIf2xx; - -import com.google.common.base.Function; -import com.google.common.base.Predicates; -import com.google.common.base.Splitter; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class SplitNewlinesAndReturnSecondField extends SplitNewlines { - - @Inject - SplitNewlinesAndReturnSecondField(ReturnStringIf2xx returnStringIf200) { - super(returnStringIf200); - } - - @Override - public Set apply(HttpResponse response) { - return ImmutableSet.copyOf(Iterables.filter( - Iterables.transform(super.apply(response), new Function() { - - @Override - public String apply(String arg0) { - if (arg0 == null) - return null; - Iterable parts = Splitter.on(' ').split(arg0); - if (Iterables.size(parts) == 2) - return Iterables.get(parts, 1); - else if (Iterables.size(parts) == 1) - return Iterables.get(parts, 0); - return null; - } - - }), Predicates.notNull())); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/handlers/CloudSigmaErrorHandler.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/handlers/CloudSigmaErrorHandler.java deleted file mode 100644 index 73bdb17e69..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/handlers/CloudSigmaErrorHandler.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.handlers; - -import java.io.IOException; - -import javax.annotation.Resource; -import javax.inject.Singleton; - -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.logging.Logger; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ResourceNotFoundException; -import org.jclouds.util.Closeables2; -import org.jclouds.util.Strings2; - -import com.google.common.base.Throwables; - -/** - * This will parse and set an appropriate exception on the command object. - * - *

- * Errors are returned with an appropriate HTTP status code, an X-Elastic- Error header specifying - * the error type, and a text description in the HTTP body. - * - * @author Adrian Cole - * - */ -@Singleton -public class CloudSigmaErrorHandler implements HttpErrorHandler { - @Resource - protected Logger logger = Logger.NULL; - - public void handleError(HttpCommand command, HttpResponse response) { - // it is important to always read fully and close streams - String message = parseMessage(response); - Exception exception = message != null ? new HttpResponseException(command, response, message) - : new HttpResponseException(command, response); - try { - message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), - response.getStatusLine()); - switch (response.getStatusCode()) { - case 400: - if ((command.getCurrentRequest().getEndpoint().getPath().endsWith("/info")) - || (message != null && message.indexOf("could not be found") != -1)) - exception = new ResourceNotFoundException(message, exception); - else if (message != null && message.indexOf("currently in use") != -1) - exception = new IllegalStateException(message, exception); - else - exception = new IllegalArgumentException(message, exception); - break; - case 401: - exception = new AuthorizationException(message, exception); - break; - case 404: - if (!command.getCurrentRequest().getMethod().equals("DELETE")) { - exception = new ResourceNotFoundException(message, exception); - } - break; - case 405: - exception = new IllegalArgumentException(message, exception); - break; - case 409: - exception = new IllegalStateException(message, exception); - break; - } - } finally { - Closeables2.closeQuietly(response.getPayload()); - command.setException(exception); - } - } - - public String parseMessage(HttpResponse response) { - if (response.getPayload() == null) - return null; - try { - return Strings2.toString(response.getPayload()); - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - try { - response.getPayload().getInput().close(); - } catch (IOException e) { - Throwables.propagate(e); - } - } - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java deleted file mode 100644 index 3d7c4cd7ef..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/options/CloneDriveOptions.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.options; - -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.jclouds.cloudsigma.domain.AffinityType; - -import com.google.common.base.Joiner; -import com.google.common.base.Splitter; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - -/** - * Contains options supported for clone drive operations.

- * Usage

The recommended way to instantiate a CloneDriveOptions object is to statically import - * CloneDriveOptions.Builder.* and invoke a static creation method followed by an instance mutator - * (if needed): - *

- * - * import static org.jclouds.cloudsigma.options.CloneDriveOptions.Builder.*; - * - * - * Payload payload = client.cloneDrive("drive-uuid","newName", size(2*1024*1024l)); - * - * - * @author Adrian Cole - * - */ -public class CloneDriveOptions { - private static final String SSD_AFFINITY_TAG = "affinity:ssd"; - private final Map options = Maps.newLinkedHashMap(); - - /** - * adjust to new size in bytes - */ - public CloneDriveOptions size(long size) { - checkArgument(size >= 0, "size must be >= 0"); - options.put("size", size + ""); - return this; - } - - public CloneDriveOptions tags(String... tags) { - // Affinity is conveyed using regular tags; make sure to preserve any already-set affinity tag. - String currentTagsString = options.remove("tags"); - Set currentTags = (currentTagsString == null) ? new HashSet() : - Sets.newLinkedHashSet(Splitter.on(' ').split(currentTagsString)); - - Set newTags = Sets.newLinkedHashSet(); - for (String tag : tags) - newTags.add(tag); - - if (currentTags.contains(SSD_AFFINITY_TAG)) - newTags.add(SSD_AFFINITY_TAG); - - options.put("tags", Joiner.on(' ').join(newTags)); - return this; - } - - /** - * Specifies whether the new drive has 'HDD' affinity (the default) or 'SSD' (for solid-state drives). - * Affinity is conveyed via a special value among the drive's tags. - */ - public CloneDriveOptions affinity(AffinityType affinity) { - // Affinity is conveyed using regular tags; make sure to avoid multiple affinity tags in the options. - String currentTagsString = options.remove("tags"); - Set tags = (currentTagsString == null) ? new LinkedHashSet() : - Sets.newLinkedHashSet(Splitter.on(' ').split(currentTagsString)); - - switch (affinity) { - // SSD affinity is conveyed as a special tag: "affinity:ssd". - case SSD: - tags.add(SSD_AFFINITY_TAG); - break; - - // HDD affinity (the default) is conveyed by the *absence* of the "affinity:ssd" tag. - case HDD: - tags.remove(SSD_AFFINITY_TAG); - break; - } - - if (!tags.isEmpty()) - options.put("tags", Joiner.on(' ').join(tags)); - - return this; - } - - public static class Builder { - - /** - * @see CloneDriveOptions#size - */ - public static CloneDriveOptions size(long size) { - CloneDriveOptions options = new CloneDriveOptions(); - return options.size(size); - } - - /** - * @see CloneDriveOptions#tags - */ - public static CloneDriveOptions tags(String... tags) { - CloneDriveOptions options = new CloneDriveOptions(); - return options.tags(tags); - } - - /** - * @see CloneDriveOptions#affinity - */ - public static CloneDriveOptions affinity(AffinityType affinity) { - CloneDriveOptions options = new CloneDriveOptions(); - return options.affinity(affinity); - } - - } - - public Map getOptions() { - return ImmutableMap.copyOf(options); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/predicates/DriveClaimed.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/predicates/DriveClaimed.java deleted file mode 100644 index 210c2efdef..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/predicates/DriveClaimed.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.predicates; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.cloudsigma.CloudSigmaApi; -import org.jclouds.cloudsigma.domain.DriveInfo; -import org.jclouds.logging.Logger; - -import com.google.common.base.Predicate; - -/** - * - * @author Adrian Cole - */ -@Singleton -public class DriveClaimed implements Predicate { - - private final CloudSigmaApi client; - - @Resource - protected Logger logger = Logger.NULL; - - @Inject - public DriveClaimed(CloudSigmaApi client) { - this.client = client; - } - - public boolean apply(DriveInfo drive) { - logger.trace("looking for claims on drive %s", checkNotNull(drive, "drive")); - drive = refresh(drive); - if (drive == null) - return false; - logger.trace("%s: looking for drive claims: currently: %s", drive.getUuid(), drive.getClaimed()); - return drive.getClaimed().size() > 0; - } - - private DriveInfo refresh(DriveInfo drive) { - return client.getDriveInfo(drive.getUuid()); - } -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/reference/CloudSigmaConstants.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/reference/CloudSigmaConstants.java deleted file mode 100644 index 535c3616bc..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/reference/CloudSigmaConstants.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.reference; - -/** - * - * @author Adrian Cole - */ -public class CloudSigmaConstants { - - /** - * default VNC password used on new machines - */ - public static final String PROPERTY_VNC_PASSWORD = "jclouds.cloudsigma.vnc-password"; - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java deleted file mode 100644 index 768f515e46..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.util; - -import org.jclouds.cloudsigma.domain.IDEDevice; -import org.jclouds.cloudsigma.domain.Model; -import org.jclouds.cloudsigma.domain.NIC; -import org.jclouds.cloudsigma.domain.Server; -import org.jclouds.cloudsigma.domain.VNC; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -public class Servers { - /** - * Helper to create a small persistent server - * - * @param name - * what to name the server - * @param driveUuuid - * id of the boot drive - * @param vncPassword - * password for vnc - * @return a builder for a persistent 1Ghz 512m server with DHCP enabled network. - */ - public static Server.Builder small(String name, String driveUuuid, String vncPassword) { - return smallWithStaticIP(name, driveUuuid, vncPassword, "auto"); - } - - /** - * Helper to create a small persistent server - * - * @param name - * what to name the server - * @param driveUuuid - * id of the boot drive - * @param vncPassword - * password for vnc - * @param ip - * static IP - * @return a builder for a persistent 1Ghz 512m server with DHCP enabled network. - */ - public static Server.Builder smallWithStaticIP(String name, String driveUuuid, String vncPassword, String ip) { - return new Server.Builder().name(name).cpu(1000).mem(512).persistent(true) - .devices(ImmutableMap.of("ide:0:0", new IDEDevice.Builder(0, 0).uuid(driveUuuid).build())) - .bootDeviceIds(ImmutableSet.of("ide:0:0")) - .nics(ImmutableSet.of(new NIC.Builder().model(Model.E1000).dhcp(ip).build())) - .vnc(new VNC(null, vncPassword, false)); - } - - /** - * Takes the input server and changes its primary ip to a new address. To make this happen, - * you'll need to invoke {@link org.jclouds.cloudsigma.CloudSigmaApi#setServerConfiguration} - * - * @param in - * server to change - * @param ip - * new ip address - * @return server with its primary nic set to the new address. - */ - public static Server changeIP(Server in, String ip) { - return Server.Builder.fromServer(in).nics(ImmutableSet.of(new NIC.Builder().model(Model.E1000).dhcp(ip).build())) - .build(); - } -} diff --git a/apis/cloudsigma/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/cloudsigma/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata deleted file mode 100644 index 768b1027f2..0000000000 --- a/apis/cloudsigma/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.cloudsigma.CloudSigmaApiMetadata \ No newline at end of file diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java deleted file mode 100644 index 2f47264cb1..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma; - -import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "CloudSigmaApiMetadataTest") -public class CloudSigmaApiMetadataTest extends BaseComputeServiceApiMetadataTest { - - public CloudSigmaApiMetadataTest() { - super(new CloudSigmaApiMetadata()); - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiTest.java deleted file mode 100644 index 24c0c4dae0..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiTest.java +++ /dev/null @@ -1,646 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma; - -import static org.jclouds.reflect.Reflection2.method; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.apis.ApiMetadata; -import org.jclouds.cloudsigma.binders.BindServerToPlainTextStringTest; -import org.jclouds.cloudsigma.domain.CreateDriveRequest; -import org.jclouds.cloudsigma.domain.Drive; -import org.jclouds.cloudsigma.domain.DriveData; -import org.jclouds.cloudsigma.domain.Server; -import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToDriveInfo; -import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToProfileInfo; -import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToServerInfo; -import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToStaticIPInfo; -import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToVLANInfo; -import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet; -import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet; -import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet; -import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet; -import org.jclouds.cloudsigma.functions.SplitNewlines; -import org.jclouds.cloudsigma.functions.SplitNewlinesAndReturnSecondField; -import org.jclouds.cloudsigma.options.CloneDriveOptions; -import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.rest.internal.BaseAsyncClientTest; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -import com.google.common.reflect.Invokable; -/** - * Tests behavior of {@code CloudSigmaApi} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "CloudSigmaApiTest") -public class CloudSigmaApiTest extends BaseAsyncClientTest { - - public void testGetProfileInfo() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "getProfileInfo"); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/profile/info HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToProfileInfo.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(httpRequest); - - } - - public void testListStandardDrives() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "listStandardDrives"); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/list HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(httpRequest); - } - - public void testListStandardCds() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "listStandardCds"); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/cd/list HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(httpRequest); - } - - public void testListStandardImages() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "listStandardImages"); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/img/list HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(httpRequest); - } - - public void testListDriveInfo() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "listDriveInfo"); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/info HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(httpRequest); - } - - public void testGetDriveInfo() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "getDriveInfo", String.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/uuid/info HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(httpRequest); - - } - - public void testCreateDrive() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "createDrive", Drive.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( - new CreateDriveRequest.Builder().name("foo").use(ImmutableList.of("production", "candy")).size(10000l) - .build())); - - assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/create HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, "name foo\nsize 10000\nuse production candy", "text/plain", false); - - assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(httpRequest); - - } - - public void testCloneDrive() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "cloneDrive", String.class, String.class, - CloneDriveOptions[].class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("sourceid", "newname")); - - assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/sourceid/clone HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, "name newname", "text/plain", false); - - assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - checkFilters(httpRequest); - - } - - public void testCloneDriveOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "cloneDrive", String.class, String.class, - CloneDriveOptions[].class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("sourceid", "newname", - new CloneDriveOptions().size(1024l))); - - assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/sourceid/clone HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, "name newname\nsize 1024", "text/plain", false); - - assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - checkFilters(httpRequest); - - } - - public void testSetDriveData() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "setDriveData", String.class, DriveData.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", new DriveData.Builder().name("foo").size(10000l) - .use(ImmutableList.of("production", "candy")).build())); - - assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/100/set HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, "name foo\nsize 10000\nuse production candy", "text/plain", false); - - assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - checkFilters(httpRequest); - - } - - public void testListServers() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "listServers"); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/list HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - // now make sure request filters apply by replaying - httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); - httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/list HTTP/1.1"); - // for example, using basic authentication, we should get "only one" - // header - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n"); - assertPayloadEquals(httpRequest, null, null, false); - - // TODO: insert expected response class, which probably extends ParseJson - assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(httpRequest); - - } - - public void testListServerInfo() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "listServerInfo"); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/info HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(httpRequest); - } - - public void testGetServerInfo() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "getServerInfo", String.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/uuid/info HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(httpRequest); - - } - - public void testCreateServer() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "createServer", Server.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(BindServerToPlainTextStringTest.SERVER)); - - assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/create HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, BindServerToPlainTextStringTest.CREATED_SERVER, "text/plain", false); - - assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(httpRequest); - - } - - public void testSetServerConfiguration() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "setServerConfiguration", String.class, Server.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", BindServerToPlainTextStringTest.SERVER)); - - assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/100/set HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, BindServerToPlainTextStringTest.CREATED_SERVER, "text/plain", false); - - assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(httpRequest); - - } - - public void testDestroyServer() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "destroyServer", String.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/uuid/destroy HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, VoidOnNotFoundOr404.class); - - checkFilters(httpRequest); - - } - - public void testStartServer() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "startServer", String.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); - - assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/start HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - checkFilters(httpRequest); - - } - - public void testStopServer() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "stopServer", String.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); - - assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/stop HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - checkFilters(httpRequest); - - } - - public void testShutdownServer() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "shutdownServer", String.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); - - assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/shutdown HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - checkFilters(httpRequest); - - } - - public void testResetServer() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "resetServer", String.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); - - assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/reset HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - checkFilters(httpRequest); - - } - - public void testListDrives() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "listDrives"); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/list HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - // now make sure request filters apply by replaying - httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); - httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/list HTTP/1.1"); - // for example, using basic authentication, we should get "only one" - // header - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n"); - assertPayloadEquals(httpRequest, null, null, false); - - // TODO: insert expected response class, which probably extends ParseJson - assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(httpRequest); - - } - - public void testDestroyDrive() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "destroyDrive", String.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/uuid/destroy HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, VoidOnNotFoundOr404.class); - - checkFilters(httpRequest); - - } - - public void testListVLANs() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "listVLANs"); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/list HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - // now make sure request filters apply by replaying - httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); - httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/list HTTP/1.1"); - // for example, using basic authentication, we should get "only one" - // header - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n"); - assertPayloadEquals(httpRequest, null, null, false); - - // TODO: insert expected response class, which probably extends ParseJson - assertResponseParserClassEquals(method, httpRequest, SplitNewlinesAndReturnSecondField.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(httpRequest); - - } - - public void testListVLANInfo() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "listVLANInfo"); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/info HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(httpRequest); - } - - public void testGetVLANInfo() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "getVLANInfo", String.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/uuid/info HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToVLANInfo.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(httpRequest); - - } - - public void testCreateVLAN() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "createVLAN", String.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("poohbear")); - - assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/vlan/create HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, "name poohbear\n", "text/plain", false); - - assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToVLANInfo.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(httpRequest); - - } - - public void testRenameVLAN() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "renameVLAN", String.class, String.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", "poohbear")); - - assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/vlan/100/set HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, "name poohbear\n", "text/plain", false); - - assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToVLANInfo.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class); - - checkFilters(httpRequest); - - } - - public void testDestroyVLAN() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "destroyVLAN", String.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/uuid/destroy HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, VoidOnNotFoundOr404.class); - - checkFilters(httpRequest); - - } - - public void testListStaticIPs() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "listStaticIPs"); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/list HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - // now make sure request filters apply by replaying - httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); - httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/list HTTP/1.1"); - // for example, using basic authentication, we should get "only one" - // header - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n"); - assertPayloadEquals(httpRequest, null, null, false); - - // TODO: insert expected response class, which probably extends ParseJson - assertResponseParserClassEquals(method, httpRequest, SplitNewlinesAndReturnSecondField.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(httpRequest); - - } - - public void testListStaticIPInfo() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "listStaticIPInfo"); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/info HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(httpRequest); - } - - public void testGetStaticIPInfo() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "getStaticIPInfo", String.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/uuid/info HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToStaticIPInfo.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(httpRequest); - - } - - public void testCreateStaticIP() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "createStaticIP"); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); - - assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/ip/create HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToStaticIPInfo.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, NullOnNotFoundOr404.class); - - checkFilters(httpRequest); - - } - - public void testDestroyStaticIP() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(CloudSigmaApi.class, "destroyStaticIP", String.class); - GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); - - assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/uuid/destroy HTTP/1.1"); - assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); - assertPayloadEquals(httpRequest, null, null, false); - - assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, VoidOnNotFoundOr404.class); - - checkFilters(httpRequest); - - } - - @Override - protected void checkFilters(HttpRequest request) { - assertEquals(request.getFilters().size(), 1); - assertEquals(request.getFilters().get(0).getClass(), BasicAuthentication.class); - } - - @Override - protected ApiMetadata createApiMetadata() { - return new CloudSigmaApiMetadata(); - } - -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java deleted file mode 100644 index 9b19e45c27..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java +++ /dev/null @@ -1,443 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma; -import static java.util.concurrent.TimeUnit.SECONDS; -import static org.jclouds.util.Predicates2.retry; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.io.IOException; -import java.util.Set; -import java.util.logging.Logger; - -import org.jclouds.cloudsigma.domain.ClaimType; -import org.jclouds.cloudsigma.domain.CreateDriveRequest; -import org.jclouds.cloudsigma.domain.DriveData; -import org.jclouds.cloudsigma.domain.DriveInfo; -import org.jclouds.cloudsigma.domain.DriveStatus; -import org.jclouds.cloudsigma.domain.DriveType; -import org.jclouds.cloudsigma.domain.IDEDevice; -import org.jclouds.cloudsigma.domain.Model; -import org.jclouds.cloudsigma.domain.ProfileInfo; -import org.jclouds.cloudsigma.domain.Server; -import org.jclouds.cloudsigma.domain.ServerInfo; -import org.jclouds.cloudsigma.domain.ServerStatus; -import org.jclouds.cloudsigma.domain.StaticIPInfo; -import org.jclouds.cloudsigma.domain.VLANInfo; -import org.jclouds.cloudsigma.options.CloneDriveOptions; -import org.jclouds.cloudsigma.predicates.DriveClaimed; -import org.jclouds.cloudsigma.util.Servers; -import org.jclouds.compute.domain.ExecResponse; -import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.predicates.SocketOpen; -import org.jclouds.ssh.SshClient; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.AfterGroups; -import org.testng.annotations.BeforeGroups; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.net.HostAndPort; -import com.google.gson.Gson; -import com.google.inject.Guice; - -/** - * Tests behavior of {@code CloudSigmaApi} - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "CloudSigmaClientLiveTest") -public class CloudSigmaClientLiveTest extends BaseComputeServiceContextLiveTest { - - public CloudSigmaClientLiveTest() { - provider = "cloudsigma"; - } - - protected long driveSize = 8 * 1024 * 1024 * 1024l; - protected int maxDriveImageTime = 300; - protected String vncPassword = "Il0veVNC"; - protected CloudSigmaApi client; - protected Predicate socketTester; - - protected Predicate driveNotClaimed; - protected String imageId; - - @BeforeGroups(groups = { "integration", "live" }) - @Override - public void setupContext() { - super.setupContext(); - - client = view.utils().injector().getInstance(CloudSigmaApi.class); - driveNotClaimed = retry(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, 1, SECONDS); - SocketOpen socketOpten = context.utils().injector().getInstance(SocketOpen.class); - socketTester = retry(socketOpten, maxDriveImageTime, 1, SECONDS); - - if (template == null || template.getImageId() == null) { - imageId = view.getComputeService().templateBuilder().build().getImage().getId(); - } - } - - @Test - public void testGetProfileInfo() throws Exception { - ProfileInfo profile = client.getProfileInfo(); - assertNotNull(profile); - } - - @Test - public void testListVLANs() throws Exception { - Set vlans = client.listVLANs(); - assertNotNull(vlans); - } - - @Test - public void testListVLANInfo() throws Exception { - Set vlans = client.listVLANInfo(); - assertNotNull(vlans); - } - - @Test - public void testGetVLAN() throws Exception { - for (String vlanUUID : client.listVLANs()) { - assert !"".equals(vlanUUID); - assertNotNull(client.getVLANInfo(vlanUUID)); - } - } - - @Test - public void testListStaticIPs() throws Exception { - Set ips = client.listStaticIPs(); - assertNotNull(ips); - } - - @Test - public void testListStaticIPInfo() throws Exception { - Set ips = client.listStaticIPInfo(); - assertNotNull(ips); - } - - @Test - public void testGetStaticIP() throws Exception { - for (String ipUUID : client.listStaticIPs()) { - assert !"".equals(ipUUID); - assertNotNull(client.getStaticIPInfo(ipUUID)); - } - } - - @Test - public void testListServers() throws Exception { - Set servers = client.listServers(); - assertNotNull(servers); - } - - @Test - public void testListServerInfo() throws Exception { - Set servers = client.listServerInfo(); - assertNotNull(servers); - } - - @Test - public void testGetServer() throws Exception { - for (String serverUUID : client.listServers()) { - assert !"".equals(serverUUID); - assertNotNull(client.getServerInfo(serverUUID)); - } - } - - @Test - public void testListDrives() throws Exception { - Set drives = client.listDrives(); - assertNotNull(drives); - } - - @Test - public void testListDriveInfo() throws Exception { - Set drives = client.listDriveInfo(); - assertNotNull(drives); - } - - @Test - public void testGetDrive() throws Exception { - for (String driveUUID : client.listStandardDrives()) { - assert !"".equals(driveUUID); - DriveInfo drive = client.getDriveInfo(driveUUID); - assertNotNull(drive); - assert !drive.getType().equals(DriveType.UNRECOGNIZED) : drive; - if (drive.getType() == DriveType.DISK && drive.getDriveType().contains("preinstalled")) - System.out.println(drive.getName()); - } - } - - protected String prefix = System.getProperty("user.name") + ".test"; - protected DriveInfo drive; - - @Test - public void testCreateDrive() throws Exception { - drive = client.createDrive(new CreateDriveRequest.Builder().name(prefix).size(driveSize).build()); - checkCreatedDrive(); - - DriveInfo newInfo = client.getDriveInfo(drive.getUuid()); - checkDriveMatchesGet(newInfo); - - } - - protected void checkDriveMatchesGet(DriveInfo newInfo) { - assertEquals(newInfo.getUuid(), drive.getUuid()); - assertEquals(newInfo.getType(), DriveType.DISK); - } - - protected void checkCreatedDrive() { - assertNotNull(drive.getUuid()); - assertNotNull(drive.getUser()); - assertEquals(drive.getName(), prefix); - assertEquals(drive.getSize(), driveSize); - assertEquals(drive.getStatus(), DriveStatus.ACTIVE); - // for some reason, these occasionally return as 4096,1 - // assertEquals(info.getReadBytes(), 0l); - // assertEquals(info.getWriteBytes(), 0l); - // assertEquals(info.getReadRequests(), 0l); - // assertEquals(info.getWriteRequests(), 0l); - assertEquals(drive.getEncryptionCipher(), "aes-xts-plain"); - assertEquals(drive.getType(), null); - } - - @Test(dependsOnMethods = "testCreateDrive") - public void testSetDriveData() throws Exception { - - DriveInfo drive2 = client.setDriveData( - drive.getUuid(), - new DriveData.Builder().claimType(ClaimType.SHARED).name("rediculous") - .readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff")) - .use(ImmutableSet.of("networking", "security", "gateway")).build()); - - assertNotNull(drive2.getUuid(), drive.getUuid()); - assertEquals(drive2.getName(), "rediculous"); - assertEquals(drive2.getClaimType(), ClaimType.SHARED); - assertEquals(drive2.getReaders(), ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff")); - assertEquals(drive2.getUse(), ImmutableSet.of("networking", "security", "gateway")); - drive = drive2; - } - - @Test - public void testCreateAndDestroyVLAN() throws Exception { - VLANInfo vlan = client.createVLAN(prefix); - String id = vlan.getUuid(); - try { - vlan = client.getVLANInfo(vlan.getUuid()); - assertEquals(vlan.getName(), prefix); - - String prefix2 = prefix + "2"; - vlan = client.renameVLAN(vlan.getUuid(), prefix2); - assertEquals(vlan.getName(), prefix2); - } finally { - client.destroyVLAN(id); - } - } - - @Test(dependsOnMethods = "testSetDriveData") - public void testCreateAndDestroyStaticIP() throws Exception { - StaticIPInfo ip = client.createStaticIP(); - StaticIPInfo ip2 = client.createStaticIP(); - Server server = null; - try { - ip = client.getStaticIPInfo(ip.getAddress()); - assertNotNull(ip); - Logger.getAnonymousLogger().info("preparing drive"); - prepareDrive(); - - Server serverRequest = Servers.smallWithStaticIP(prefix, drive.getUuid(), vncPassword, ip.getAddress()) - .build(); - - Logger.getAnonymousLogger().info("starting server"); - server = client.createServer(serverRequest); - assertEquals(server.getNics().get(0).getDhcp(), ip.getAddress()); - client.stopServer(server.getUuid()); - server = client.setServerConfiguration(server.getUuid(), Servers.changeIP(server, ip2.getAddress())); - assertEquals(server.getNics().get(0).getDhcp(), ip2.getAddress()); - } finally { - if (server != null) { - client.destroyServer(server.getUuid()); - client.destroyDrive(drive.getUuid()); - } - client.destroyStaticIP(ip.getAddress()); - client.destroyStaticIP(ip2.getAddress()); - } - } - - protected ServerInfo server; - - @Test(dependsOnMethods = "testCreateAndDestroyStaticIP") - public void testCreateAndStartServer() throws Exception { - Logger.getAnonymousLogger().info("preparing drive"); - prepareDrive(); - - Server serverRequest = Servers.small(prefix, drive.getUuid(), vncPassword).build(); - - Logger.getAnonymousLogger().info("starting server"); - server = client.createServer(serverRequest); - client.startServer(server.getUuid()); - server = client.getServerInfo(server.getUuid()); - checkStartedServer(); - - Server newInfo = client.getServerInfo(server.getUuid()); - checkServerMatchesGet(newInfo); - - } - - protected void checkServerMatchesGet(Server newInfo) { - assertEquals(newInfo.getUuid(), server.getUuid()); - } - - protected void checkStartedServer() { - System.out.println(new Gson().toJson(server)); - assertNotNull(server.getUuid()); - assertNotNull(server.getUser()); - assertEquals(server.getName(), prefix); - assertEquals(server.isPersistent(), true); - assertEquals(server.getDevices(), - ImmutableMap.of("ide:0:0", new IDEDevice.Builder(0, 0).uuid(drive.getUuid()).build())); - assertEquals(server.getBootDeviceIds(), ImmutableSet.of("ide:0:0")); - assertEquals(server.getNics().get(0).getDhcp(), server.getVnc().getIp()); - assertEquals(server.getNics().get(0).getModel(), Model.E1000); - assertEquals(server.getStatus(), ServerStatus.ACTIVE); - } - - @Test(dependsOnMethods = "testCreateAndStartServer") - public void testConnectivity() throws Exception { - Logger.getAnonymousLogger().info("awaiting vnc"); - assert socketTester.apply(HostAndPort.fromParts(server.getVnc().getIp(), 5900)) : server; - Logger.getAnonymousLogger().info("awaiting ssh"); - assert socketTester.apply(HostAndPort.fromParts(server.getNics().get(0).getDhcp(), 22)) : server; - doConnectViaSsh(server, getSshCredentials(server)); - } - - @Test(dependsOnMethods = "testConnectivity") - public void testLifeCycle() throws Exception { - client.stopServer(server.getUuid()); - assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.STOPPED); - - client.startServer(server.getUuid()); - assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.ACTIVE); - - client.resetServer(server.getUuid()); - assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.ACTIVE); - - client.shutdownServer(server.getUuid()); - // behavior on shutdown depends on how your server OS is set up to respond - // to an ACPI power - // button signal - assert client.getServerInfo(server.getUuid()).getStatus() == ServerStatus.ACTIVE || client.getServerInfo( - server.getUuid()).getStatus() == ServerStatus.STOPPED; - } - - @Test(dependsOnMethods = "testLifeCycle") - public void testSetServerConfiguration() throws Exception { - client.stopServer(server.getUuid()); - assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.STOPPED); - - ServerInfo server2 = client.setServerConfiguration( - server.getUuid(), - Server.Builder.fromServer(server).name("rediculous") - .use(ImmutableSet.of("networking", "security", "gateway")).build()); - - assertNotNull(server2.getUuid(), server.getUuid()); - assertEquals(server2.getName(), "rediculous"); - checkUse(server2); - server = server2; - } - - protected void checkUse(ServerInfo server2) { - // bug where use aren't updated - assertEquals(server2.getUse(), ImmutableSet. of()); - } - - @Test(dependsOnMethods = "testSetServerConfiguration") - public void testDestroyServer() throws Exception { - client.destroyServer(server.getUuid()); - assertEquals(client.getServerInfo(server.getUuid()), null); - } - - @Test(dependsOnMethods = "testDestroyServer") - public void testDestroyDrive() throws Exception { - client.destroyDrive(drive.getUuid()); - assertEquals(client.getDriveInfo(drive.getUuid()), null); - } - - protected void doConnectViaSsh(Server server, LoginCredentials creds) throws IOException { - SshClient ssh = Guice.createInjector(new SshjSshClientModule()).getInstance(SshClient.Factory.class) - .create(HostAndPort.fromParts(server.getVnc().getIp(), 22), creds); - try { - ssh.connect(); - ExecResponse hello = ssh.exec("echo hello"); - assertEquals(hello.getOutput().trim(), "hello"); - System.err.println(ssh.exec("df -k").getOutput()); - System.err.println(ssh.exec("mount").getOutput()); - System.err.println(ssh.exec("uname -a").getOutput()); - } finally { - if (ssh != null) - ssh.disconnect(); - } - } - - @AfterGroups(groups = "live") - @Override - protected void tearDownContext() { - if (server != null) - client.destroyServer(server.getUuid()); - if (server != null) - client.destroyDrive(drive.getUuid()); - super.tearDownContext(); - } - - @Test - public void testListStandardDrives() throws Exception { - Set drives = client.listStandardDrives(); - assertNotNull(drives); - } - - @Test - public void testListStandardCds() throws Exception { - Set drives = client.listStandardCds(); - assertNotNull(drives); - } - - @Test - public void testListStandardImages() throws Exception { - Set drives = client.listStandardImages(); - assertNotNull(drives); - } - - protected LoginCredentials getSshCredentials(Server server) { - return LoginCredentials.builder().user("root").password(vncPassword).build(); - } - - protected void prepareDrive() { - client.destroyDrive(drive.getUuid()); - drive = client.cloneDrive(imageId, drive.getName(), - new CloneDriveOptions().size(driveSize).tags("cat:mouse", "monkey:banana")); - // Block until the async clone operation has completed. - assert driveNotClaimed.apply(drive) : client.getDriveInfo(drive.getUuid()); - - DriveInfo clonedDrive = client.getDriveInfo(drive.getUuid()); - System.err.println("after prepare" + clonedDrive); - assertEquals(clonedDrive.getTags(), ImmutableSet.of("cat:mouse", "monkey:banana")); - } - -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextStringTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextStringTest.java deleted file mode 100644 index 789edaee20..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextStringTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.binders; - -import static org.jclouds.reflect.Reflection2.method; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.net.URI; -import java.util.List; -import java.util.Map; - -import org.jclouds.cloudsigma.options.CloneDriveOptions; -import org.jclouds.reflect.Invocation; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.Test; - -import com.google.common.base.Throwables; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.inject.Guice; -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class BindCloneDriveOptionsToPlainTextStringTest { - - private static final BindCloneDriveOptionsToPlainTextString binder = Guice.createInjector().getInstance( - BindCloneDriveOptionsToPlainTextString.class); - - public void testDefault() throws IOException { - String expected = "name newdrive"; - GeneratedHttpRequest request = requestForArgs(ImmutableList. of()); - - Map map = ImmutableMap. of("name", "newdrive"); - assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected); - } - - public void testWithSize() throws IOException { - String expected = "name newdrive\nsize 1024"; - GeneratedHttpRequest request = requestForArgs(ImmutableList. of(new CloneDriveOptions().size(1024))); - - Map map = ImmutableMap. of("name", "newdrive"); - assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected); - } - - protected GeneratedHttpRequest requestForArgs(List args) { - try { - Invocation invocation = Invocation.create(method(String.class, "toString"), args); - return GeneratedHttpRequest.builder().method("POST").endpoint(URI.create("http://localhost/key")) - .invocation(invocation).build(); - } catch (SecurityException e) { - throw Throwables.propagate(e); - } - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindDriveDataToPlainTextStringTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindDriveDataToPlainTextStringTest.java deleted file mode 100644 index 5deb8fa9d8..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindDriveDataToPlainTextStringTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.binders; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Map; - -import javax.ws.rs.core.MediaType; - -import org.jclouds.cloudsigma.domain.ClaimType; -import org.jclouds.cloudsigma.domain.Drive; -import org.jclouds.cloudsigma.domain.DriveData; -import org.jclouds.cloudsigma.functions.BaseDriveToMap; -import org.jclouds.cloudsigma.functions.DriveDataToMap; -import org.jclouds.http.HttpRequest; -import org.jclouds.util.Strings2; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.TypeLiteral; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class BindDriveDataToPlainTextStringTest { - - private static final BindDriveDataToPlainTextString FN = Guice.createInjector(new AbstractModule() { - - @Override - protected void configure() { - bind(new TypeLiteral>>() { - }).to(BaseDriveToMap.class); - bind(new TypeLiteral>>() { - }).to(DriveDataToMap.class); - } - - }).getInstance(BindDriveDataToPlainTextString.class); - - public void testSimple() { - HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://host/drives/create").build(); - FN.bindToRequest(request, new DriveData.Builder().name("foo").size(100l).build()); - assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN); - assertEquals(request.getPayload().getRawContent(), "name foo\nsize 100"); - } - - public void testComplete() throws IOException { - DriveData input = new DriveData.Builder().name("Ubuntu 10.10 Server Edition Linux 64bit Preinstalled System") - // - .size(8589934592l)// - .claimType(ClaimType.SHARED)// - .tags(ImmutableSet.of("foo", "bar", "baz"))// - .readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff"))// - .use(ImmutableSet.of("tag1", "tag2"))// - .build(); - - HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://host/drives/create").build(); - FN.bindToRequest(request, input); - assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN); - assertEquals(request.getPayload().getRawContent(), - Strings2.toStringAndClose(BindDriveDataToPlainTextStringTest.class.getResourceAsStream("/drive_data.txt"))); - - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindDriveToPlainTextStringTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindDriveToPlainTextStringTest.java deleted file mode 100644 index 78a793f39b..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindDriveToPlainTextStringTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.binders; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Map; - -import javax.ws.rs.core.MediaType; - -import org.jclouds.cloudsigma.domain.ClaimType; -import org.jclouds.cloudsigma.domain.CreateDriveRequest; -import org.jclouds.cloudsigma.domain.Drive; -import org.jclouds.cloudsigma.domain.DriveData; -import org.jclouds.cloudsigma.functions.BaseDriveToMap; -import org.jclouds.cloudsigma.functions.DriveDataToMap; -import org.jclouds.http.HttpRequest; -import org.jclouds.util.Strings2; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.TypeLiteral; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class BindDriveToPlainTextStringTest { - - private static final BindDriveToPlainTextString FN = Guice.createInjector(new AbstractModule() { - - @Override - protected void configure() { - bind(new TypeLiteral>>() { - }).to(BaseDriveToMap.class); - bind(new TypeLiteral>>() { - }).to(DriveDataToMap.class); - } - - }).getInstance(BindDriveToPlainTextString.class); - - public void testSimple() { - HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://host/drives/create").build(); - FN.bindToRequest(request, new CreateDriveRequest.Builder().name("foo").size(100l).build()); - assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN); - assertEquals(request.getPayload().getRawContent(), "name foo\nsize 100"); - } - - public void testComplete() throws IOException { - CreateDriveRequest input = new CreateDriveRequest.Builder() - .name("Ubuntu 10.10 Server Edition Linux 64bit Preinstalled System") - // - .size(8589934592l)// - .claimType(ClaimType.SHARED)// - .readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff"))// - .use(ImmutableSet.of("tag1", "tag2"))// - .encryptionCipher("aes-xts-plain").avoid(ImmutableSet.of("avoid1")).build(); - - HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://host/drives/create").build(); - FN.bindToRequest(request, input); - assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN); - assertEquals(request.getPayload().getRawContent(), - Strings2.toStringAndClose(BindDriveToPlainTextStringTest.class - .getResourceAsStream("/create_drive.txt"))); - - } - -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindServerToPlainTextStringTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindServerToPlainTextStringTest.java deleted file mode 100644 index fc9d004e1d..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindServerToPlainTextStringTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.binders; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Map; - -import javax.ws.rs.core.MediaType; - -import org.jclouds.cloudsigma.domain.IDEDevice; -import org.jclouds.cloudsigma.domain.Model; -import org.jclouds.cloudsigma.domain.NIC; -import org.jclouds.cloudsigma.domain.Server; -import org.jclouds.cloudsigma.domain.VNC; -import org.jclouds.cloudsigma.functions.ServerToMap; -import org.jclouds.http.HttpRequest; -import org.jclouds.util.Strings2; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.common.base.Throwables; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.TypeLiteral; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class BindServerToPlainTextStringTest { - - public static final String CREATED_SERVER; - static { - try { - CREATED_SERVER = Strings2.toStringAndClose(BindServerToPlainTextStringTest.class - .getResourceAsStream("/create_server.txt")); - } catch (IOException e) { - throw Throwables.propagate(e); - } - } - public static final Server SERVER = new Server.Builder() - .name("TestServer") - .cpu(2000) - .mem(1024) - .devices( - ImmutableMap.of("ide:0:0", new IDEDevice.Builder(0, 0).uuid("08c92dd5-70a0-4f51-83d2-835919d254df") - .build())).bootDeviceIds(ImmutableSet.of("ide:0:0")) - .nics(ImmutableSet.of(new NIC.Builder().model(Model.E1000). - - build())).vnc(new VNC(null, "XXXXXXXX", false)).build(); - private static final BindServerToPlainTextString FN = Guice.createInjector(new AbstractModule() { - - @Override - protected void configure() { - bind(new TypeLiteral>>() { - }).to(ServerToMap.class); - bind(new TypeLiteral>>() { - }).to(ServerToMap.class); - } - - }).getInstance(BindServerToPlainTextString.class); - - public void testSimple() throws IOException { - HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://host/drives/create").build(); - FN.bindToRequest(request, SERVER); - assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN); - assertEquals(request.getPayload().getRawContent(), CREATED_SERVER); - } - -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java deleted file mode 100644 index eaf5e2b54e..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.compute; - -import org.jclouds.compute.domain.ExecResponse; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -/** - * @author Adrian Cole - */ -@Test(groups = "live", testName = "CloudSigmaComputeServiceLiveTest") -public class CloudSigmaComputeServiceLiveTest extends BaseComputeServiceLiveTest { - - public CloudSigmaComputeServiceLiveTest() { - provider = "cloudsigma"; - } - - @Override - protected Module getSshModule() { - return new SshjSshClientModule(); - } - - // cloudsigma does not support metadata - @Override - protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap userMetadata) { - assert node.getUserMetadata().equals(ImmutableMap. of()) : String.format( - "node userMetadata did not match %s %s", userMetadata, node); - } - - // cloudsigma does not support tags - @Override - protected void checkTagsInNodeEquals(final NodeMetadata node, final ImmutableSet tags) { - assert node.getTags().equals(ImmutableSet. of()) : String.format("node tags did not match %s %s", tags, - node); - } - - protected void checkResponseEqualsHostname(ExecResponse execResponse, NodeMetadata node1) { - // hostname is not predictable based on node metadata - assert execResponse.getOutput().trim().equals("ubuntu"); - } - - @Override - public void testOptionToNotBlock() { - // start call has to block until we have a pool of reserved pre-cloned drives. - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/BaseDriveToMapTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/BaseDriveToMapTest.java deleted file mode 100644 index 7fcfbd280b..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/BaseDriveToMapTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; - -import org.jclouds.cloudsigma.domain.ClaimType; -import org.jclouds.cloudsigma.domain.Drive; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class BaseDriveToMapTest { - - private static final BaseDriveToMap BASEDRIVE_TO_MAP = new BaseDriveToMap(); - - public void testBasics() { - assertEquals(BASEDRIVE_TO_MAP.apply(new Drive.Builder().name("foo").size(100l).build()), - ImmutableMap.of("name", "foo", "size", "100")); - } - - public void testComplete() throws IOException { - Drive one = new Drive.Builder().name("Ubuntu 10.10 Server Edition Linux 64bit Preinstalled System") - // - .size(8589934592l)// - .claimType(ClaimType.SHARED)// - .tags(ImmutableSet.of("foo", "bar", "baz"))// - .readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff"))// - .use(ImmutableSet.of("tag1", "tag2"))// - .build(); - assertEquals( - BASEDRIVE_TO_MAP.apply(one), - ImmutableMap.builder().put("name", "Ubuntu 10.10 Server Edition Linux 64bit Preinstalled System") - .put("size", "8589934592") - .put("claim:type", "shared") - .put("tags", "foo bar baz") - .put("readers", "ffffffff-ffff-ffff-ffff-ffffffffffff").put("use", "tag1 tag2").build() - - ); - - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/DriveDataToMapTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/DriveDataToMapTest.java deleted file mode 100644 index 9c29d4da2d..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/DriveDataToMapTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Map; - -import org.jclouds.cloudsigma.domain.ClaimType; -import org.jclouds.cloudsigma.domain.DriveData; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Guice; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class DriveDataToMapTest { - - public void testRenameKeyWhenNotFound() { - Map nothing = ImmutableMap.of(); - assertEquals(DriveDataToMap.renameKey(nothing, "foo", "bar"), nothing); - } - - public void testRenameKeyWhenFound() { - Map nothing = ImmutableMap.of("foo", "bar"); - assertEquals(DriveDataToMap.renameKey(nothing, "foo", "bar"), ImmutableMap.of("bar", "bar")); - } - - private static final DriveDataToMap BASEDRIVE_TO_MAP = Guice.createInjector().getInstance(DriveDataToMap.class); - - public void testBasics() { - assertEquals(BASEDRIVE_TO_MAP.apply(new DriveData.Builder().name("foo").size(100l).build()), - ImmutableMap.of("name", "foo", "size", "100")); - } - - public void testComplete() throws IOException { - DriveData one = new DriveData.Builder().name("Ubuntu 10.10 Server Edition Linux 64bit Preinstalled System") - // - .size(8589934592l)// - .claimType(ClaimType.SHARED)// - .tags(ImmutableSet.of("foo", "bar", "baz"))// - .readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff"))// - .use(ImmutableSet.of("tag1", "tag2"))// - .build(); - assertEquals( - BASEDRIVE_TO_MAP.apply(one), - ImmutableMap.builder() - .put("name", "Ubuntu 10.10 Server Edition Linux 64bit Preinstalled System") - .put("size", "8589934592") - .put("claim:type", "shared") - .put("tags", "foo bar baz") - .put("readers", "ffffffff-ffff-ffff-ffff-ffffffffffff") - .put("use", "tag1 tag2").build() - - ); - - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToDriveInfoTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToDriveInfoTest.java deleted file mode 100644 index dd2aa5c07d..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToDriveInfoTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.inject.Guice; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class KeyValuesDelimitedByBlankLinesToDriveInfoTest { - - private static final KeyValuesDelimitedByBlankLinesToDriveInfo FN = Guice.createInjector().getInstance( - KeyValuesDelimitedByBlankLinesToDriveInfo.class); - - public void testNone() { - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), null); - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), null); - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), null); - } - - public void testOne() { - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToDriveInfoTest.class - .getResourceAsStream("/drive.txt")).build()), MapToDriveInfoTest.ONE); - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToProfileInfoTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToProfileInfoTest.java deleted file mode 100644 index 7c53d2c748..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToProfileInfoTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.inject.Guice; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class KeyValuesDelimitedByBlankLinesToProfileInfoTest { - - private static final KeyValuesDelimitedByBlankLinesToProfileInfo FN = Guice.createInjector().getInstance( - KeyValuesDelimitedByBlankLinesToProfileInfo.class); - - public void testNone() { - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), null); - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), null); - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), null); - } - - public void testOne() { - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToProfileInfoTest.class - .getResourceAsStream("/profile.txt")).build()), MapToProfileInfoTest.ONE); - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToServerInfoTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToServerInfoTest.java deleted file mode 100644 index 4e5598b9df..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToServerInfoTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static org.testng.Assert.assertEquals; - -import java.util.List; -import java.util.Map; - -import org.jclouds.cloudsigma.domain.Device; -import org.jclouds.cloudsigma.domain.DriveMetrics; -import org.jclouds.cloudsigma.domain.NIC; -import org.jclouds.cloudsigma.domain.ServerMetrics; -import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.TypeLiteral; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class KeyValuesDelimitedByBlankLinesToServerInfoTest { - - private static final KeyValuesDelimitedByBlankLinesToServerInfo FN = Guice.createInjector(new AbstractModule() { - - @Override - protected void configure() { - bind(new TypeLiteral, List>>() { - }).to(MapToNICs.class); - bind(new TypeLiteral, Map>>() { - }).to(MapToDevices.class); - bind(new TypeLiteral, Map>>() { - }).to(MapToDriveMetrics.class); - bind(new TypeLiteral, ServerMetrics>>() { - }).to(MapToServerMetrics.class); - bind(new TypeLiteral>() { - }).to(DeviceToId.class); - } - - }).getInstance(KeyValuesDelimitedByBlankLinesToServerInfo.class); - - public void testNone() { - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), null); - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), null); - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), null); - } - - public void testOne() { - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToServerInfoTest.class - .getResourceAsStream("/servers.txt")).build()), MapToServerInfoTest.ONE); - } - - public void testNew() { - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToServerInfoTest.class - .getResourceAsStream("/new_server.txt")).build()), MapToServerInfoTest.NEW); - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToVLANInfoTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToVLANInfoTest.java deleted file mode 100644 index 5c4185dce3..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/KeyValuesDelimitedByBlankLinesToVLANInfoTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.inject.Guice; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class KeyValuesDelimitedByBlankLinesToVLANInfoTest { - - private static final KeyValuesDelimitedByBlankLinesToVLANInfo FN = Guice.createInjector().getInstance( - KeyValuesDelimitedByBlankLinesToVLANInfo.class); - - public void testNone() { - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), null); - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), null); - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), null); - } - - public void testOne() { - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToVLANInfoTest.class - .getResourceAsStream("/vlan.txt")).build()), MapToVLANInfoTest.ONE); - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSetTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSetTest.java deleted file mode 100644 index 4959f4de25..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSetTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.cloudsigma.domain.DriveInfo; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Guice; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSetTest { - - private static final ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet FN = Guice.createInjector().getInstance( - ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class); - - public void testNone() { - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), ImmutableSet. of()); - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), ImmutableSet. of()); - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), ImmutableSet. of()); - } - - public void testOne() { - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToDriveInfoTest.class - .getResourceAsStream("/drive.txt")).build()), ImmutableSet. of(MapToDriveInfoTest.ONE)); - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToListOfMapsTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToListOfMapsTest.java deleted file mode 100644 index 7b7f0cfb14..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToListOfMapsTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static org.testng.Assert.assertEquals; - -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class ListOfKeyValuesDelimitedByBlankLinesToListOfMapsTest { - - private static final ListOfKeyValuesDelimitedByBlankLinesToListOfMaps FN = new ListOfKeyValuesDelimitedByBlankLinesToListOfMaps(); - - public void testNone() { - assertEquals(FN.apply(""), Lists.newArrayList()); - assertEquals(FN.apply("\n\n\n"), Lists.newArrayList()); - } - - public void testOneMap() { - assertEquals(FN.apply("key1 value1\nkey2 value2"), - ImmutableList.of(ImmutableMap.of("key1", "value1", "key2", "value2"))); - assertEquals(FN.apply("key1 value1\nkey2 value2\n\n"), - ImmutableList.of(ImmutableMap.of("key1", "value1", "key2", "value2"))); - } - - public void testValueEncodesNewlines() { - assertEquals(FN.apply("key1 value1\\n\nkey2 value2"), - ImmutableList.of(ImmutableMap.of("key1", "value1\n", "key2", "value2"))); - } - - public void testTwoMaps() { - assertEquals( - FN.apply("key1 value1\nkey2 value2\n\nkey1 v1\nkey2 v2"), - ImmutableList.of(ImmutableMap.of("key1", "value1", "key2", "value2"), - ImmutableMap.of("key1", "v1", "key2", "v2"))); - assertEquals( - FN.apply("key1 value1\nkey2 value2\n\nkey1 v1\nkey2 v2\n\n"), - ImmutableList.of(ImmutableMap.of("key1", "value1", "key2", "value2"), - ImmutableMap.of("key1", "v1", "key2", "v2"))); - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToServerInfoSetTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToServerInfoSetTest.java deleted file mode 100644 index 31f8fe05b1..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToServerInfoSetTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static org.testng.Assert.assertEquals; - -import java.util.List; -import java.util.Map; - -import org.jclouds.cloudsigma.domain.Device; -import org.jclouds.cloudsigma.domain.DriveMetrics; -import org.jclouds.cloudsigma.domain.NIC; -import org.jclouds.cloudsigma.domain.ServerInfo; -import org.jclouds.cloudsigma.domain.ServerMetrics; -import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.TypeLiteral; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class ListOfKeyValuesDelimitedByBlankLinesToServerInfoSetTest { - - private static final ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet FN = Guice.createInjector( - new AbstractModule() { - - @Override - protected void configure() { - bind(new TypeLiteral, List>>() { - }).to(MapToNICs.class); - bind(new TypeLiteral, Map>>() { - }).to(MapToDevices.class); - bind(new TypeLiteral, Map>>() { - }).to(MapToDriveMetrics.class); - bind(new TypeLiteral, ServerMetrics>>() { - }).to(MapToServerMetrics.class); - bind(new TypeLiteral>() { - }).to(DeviceToId.class); - } - - }).getInstance(ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.class); - - public void testNone() { - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), ImmutableSet. of()); - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), - ImmutableSet. of()); - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), ImmutableSet. of()); - } - - public void testOne() { - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToServerInfoTest.class - .getResourceAsStream("/servers.txt")).build()), ImmutableSet. of(MapToServerInfoTest.ONE, - MapToServerInfoTest.TWO)); - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSetTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSetTest.java deleted file mode 100644 index 8fe5a51bed..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSetTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.cloudsigma.domain.VLANInfo; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Guice; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSetTest { - - private static final ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet FN = Guice.createInjector().getInstance( - ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.class); - - public void testNone() { - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), ImmutableSet. of()); - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), ImmutableSet. of()); - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), ImmutableSet. of()); - } - - public void testOne() { - assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToVLANInfoTest.class - .getResourceAsStream("/vlan.txt")).build()), ImmutableSet. of(MapToVLANInfoTest.ONE)); - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfMapsToListOfKeyValuesDelimitedByBlankLinesTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfMapsToListOfKeyValuesDelimitedByBlankLinesTest.java deleted file mode 100644 index 7302f20b96..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ListOfMapsToListOfKeyValuesDelimitedByBlankLinesTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static org.testng.Assert.assertEquals; - -import java.util.Map; - -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class ListOfMapsToListOfKeyValuesDelimitedByBlankLinesTest { - - private static final ListOfMapsToListOfKeyValuesDelimitedByBlankLines FN = new ListOfMapsToListOfKeyValuesDelimitedByBlankLines(); - - public void testNone() { - assertEquals(FN.apply(ImmutableList.> of()), ""); - } - - public void testOneMap() { - assertEquals( - FN.apply(ImmutableList.> of(ImmutableMap.of("key1", "value1", "key2", "value2"))), - "key1 value1\nkey2 value2"); - } - - public void testValueEncodesNewlines() { - assertEquals( - FN.apply(ImmutableList.> of(ImmutableMap.of("key1", "value1\n", "key2", "value2"))), - "key1 value1\\n\nkey2 value2"); - } - - public void testTwoMaps() { - assertEquals(FN.apply(ImmutableList.> of(ImmutableMap.of("key1", "value1", "key2", "value2"), - ImmutableMap.of("key1", "v1", "key2", "v2"))), "key1 value1\nkey2 value2\n\nkey1 v1\nkey2 v2"); - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToDriveInfoTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToDriveInfoTest.java deleted file mode 100644 index d55af5e208..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToDriveInfoTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.net.URI; -import java.util.Map; - -import org.jclouds.cloudsigma.domain.ClaimType; -import org.jclouds.cloudsigma.domain.DriveInfo; -import org.jclouds.cloudsigma.domain.DriveMetrics; -import org.jclouds.cloudsigma.domain.DriveStatus; -import org.jclouds.cloudsigma.domain.DriveType; -import org.jclouds.util.Strings2; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class MapToDriveInfoTest { - public static DriveInfo ONE = new DriveInfo.Builder() - .status(DriveStatus.ACTIVE) - .use(ImmutableSet.of("networking", "security", "gateway")) - .name("Ubuntu 10.10 Server Edition Linux 64bit Preinstalled System") - .bits(64) - .url(URI.create("http://www.ubuntu.com")) - .metrics( - new DriveMetrics.Builder().readBytes(4096l).writeBytes(8589938688l).readRequests(1l) - .writeRequests(2097153l).build()) - .user("58ca3c1f-7629-4771-9b71-863f40153ba4") - .encryptionCipher("aes-xts-plain") - .encryptionKey("ba6c2a4897072e9f25920ed73bd522e9c10d89f30a215158cccf8d0f654ac643") - .description("The Ubuntu Linux distribution brings the spirit of Ubuntu to the software world.") - .tags(ImmutableSet.of("foo", "bar", "baz")) - .uuid("b8171d28-755a-4271-b891-7998871a160e") - .installNotes("first line\n\n") - .os("linux") - .claimType(ClaimType.SHARED) - .claimed( - ImmutableSet.of( - "00109617-2c6b-424b-9cfa-5b572c17bafe:guest:692cd1c7-a863-4a22-8170-fc6e6feb68af:ide:0:0", - "00031836-a624-4b22-bc7d-41ff8977087b:guest:a1414360-7c24-4730-8c97-180bf7775a71:ide:0:0", - "0002c6df-a1d2-4d1d-96f0-f95405a28183:guest:386f1cc7-affc-49c1-82a5-2f8e412170e4:ide:0:0", - "00031836-a624-4b22-bc7d-41ff8977087b:guest:17b076be-430d-4a76-9df3-b9896fec82a5:ide:0:0", - "000663ee-9fb6-4461-90f6-01327a4aff07:guest:f83b519f-feab-42cf-859c-f61495681ada:ide:0:1"))// - .driveType(ImmutableSet.of("installcd", "livecd"))// - .autoexpanding(false).readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff"))// - .free(true)// - .type(DriveType.DISK)// - .size(8589934592l)// - .build(); - - private static final MapToDriveInfo MAP_TO_DRIVE = new MapToDriveInfo(); - - public void testEmptyMapReturnsNull() { - assertEquals(MAP_TO_DRIVE.apply(ImmutableMap. of()), null); - } - - public void testBasics() { - DriveInfo expects = new DriveInfo.Builder().name("foo").size(100l).metrics(new DriveMetrics.Builder().build()) - .build(); - assertEquals(MAP_TO_DRIVE.apply(ImmutableMap.of("name", "foo", "size", "100")), expects); - } - - public void testComplete() throws IOException { - - Map input = new ListOfKeyValuesDelimitedByBlankLinesToListOfMaps().apply( - Strings2.toStringAndClose(MapToDriveInfoTest.class.getResourceAsStream("/drive.txt"))).get(0); - - assertEquals(MAP_TO_DRIVE.apply(input), ONE); - - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToProfileInfoTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToProfileInfoTest.java deleted file mode 100644 index 55ea043e56..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToProfileInfoTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Map; - -import org.jclouds.cloudsigma.domain.ProfileInfo; -import org.jclouds.cloudsigma.domain.ProfileType; -import org.jclouds.util.Strings2; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class MapToProfileInfoTest { - public static ProfileInfo ONE = new ProfileInfo.Builder().type(ProfileType.REGULAR)// - .uuid("58ca3c1f-7629-4771-9b71-863f40153ba4")// - .email("adrian@jclouds.org").firstName("Adrian").lastName("Cole").nickName("jclouds").build(); - - private static final MapToProfileInfo MAP_TO_PROFILE = new MapToProfileInfo(); - - public void testEmptyMapReturnsNull() { - assertEquals(MAP_TO_PROFILE.apply(ImmutableMap. of()), null); - } - - public void test() throws IOException { - - Map input = new ListOfKeyValuesDelimitedByBlankLinesToListOfMaps().apply( - Strings2.toStringAndClose(MapToProfileInfoTest.class.getResourceAsStream("/profile.txt"))).get(0); - - assertEquals(MAP_TO_PROFILE.apply(input), ONE); - - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToServerInfoTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToServerInfoTest.java deleted file mode 100644 index d0b46c6f65..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToServerInfoTest.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Date; -import java.util.Map; - -import org.jclouds.cloudsigma.domain.DriveMetrics; -import org.jclouds.cloudsigma.domain.IDEDevice; -import org.jclouds.cloudsigma.domain.MediaType; -import org.jclouds.cloudsigma.domain.Model; -import org.jclouds.cloudsigma.domain.NIC; -import org.jclouds.cloudsigma.domain.ServerInfo; -import org.jclouds.cloudsigma.domain.ServerMetrics; -import org.jclouds.cloudsigma.domain.ServerStatus; -import org.jclouds.cloudsigma.domain.VNC; -import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId; -import org.jclouds.util.Strings2; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class MapToServerInfoTest { - public static ServerInfo ONE = new ServerInfo.Builder() - .persistent(true) - .uuid("f8bee9cd-8e4b-4a05-8593-1314e3bfe49b") - .cpu(2000) - .bootDeviceIds(ImmutableSet.of("ide:0:0")) - .smp(1) - .mem(1024) - .status(ServerStatus.ACTIVE) - .started(new Date(1291493868l)) - .user("2f6244eb-50bc-4403-847e-f03cc3706a1f") - .name("jo") - .vnc(new VNC("46.20.114.124", "HfHzVmLT", false)) - .nics(ImmutableSet.of(new NIC.Builder() - .model(Model.E1000) - .dhcp("46.20.114.124") - .block( - ImmutableList.of("tcp/43594", "tcp/5902", "udp/5060", "tcp/5900", "tcp/5901", "tcp/21", "tcp/22", - "tcp/23", "tcp/25", "tcp/110", "tcp/143", "tcp/43595")).build())) - .devices( - ImmutableMap.of("ide:0:0", - new IDEDevice.Builder(0, 0).uuid("4af85ed3-0caa-4736-8a26-a33d7de0a122").build() - - )) - .metrics( - new ServerMetrics.Builder() - .tx(2550) - .txPackets(31) - .rx(455530) - .rxPackets(7583) - .driveMetrics( - ImmutableMap.of("ide:0:0", new DriveMetrics.Builder().readRequests(11154) - .readBytes(45686784).writeRequests(3698).writeBytes(15147008).build())).build()) - .build(); - - public static ServerInfo TWO = new ServerInfo.Builder() - .status(ServerStatus.STOPPED) - .name("Demo") - .mem(1024) - .cpu(2000) - .persistent(true) - .uuid("0f962616-2071-4173-be79-7dd084271edf") - .bootDeviceIds(ImmutableSet.of("ide:0:0")) - .user("2f6244eb-50bc-4403-847e-f03cc3706a1f") - .vnc(new VNC("auto", "HWbjvrg2", false)) - .nics(ImmutableSet.of(new NIC.Builder().model(Model.E1000).dhcp("auto").build())) - .devices( - ImmutableMap.of( - "ide:0:0", - new IDEDevice.Builder(0, 0).uuid("853bb98a-4fff-4c2f-a265-97c363f19ea5") - .mediaType(MediaType.CDROM).build())) - .metrics( - new ServerMetrics.Builder().driveMetrics(ImmutableMap.of("ide:0:0", new DriveMetrics.Builder().build())) - .build()).build(); - - private static final MapToServerInfo MAP_TO_DRIVE = new MapToServerInfo(new MapToDevices(new DeviceToId()), - new MapToServerMetrics(new MapToDriveMetrics()), new MapToNICs()); - - public void testEmptyMapReturnsNull() { - assertEquals(MAP_TO_DRIVE.apply(ImmutableMap. of()), null); - } - - public void testBasics() { - ServerInfo expects = new ServerInfo.Builder().name("foo").uuid("hello").vnc(new VNC("auto", null, false)) - .cpu(1000).mem(2048).metrics(new ServerMetrics.Builder().build()).build(); - assertEquals(MAP_TO_DRIVE.apply(ImmutableMap.of("name", "foo", "server", "hello", "vnc:ip", "auto", "cpu", - "1000", "mem", "2048")), expects); - } - - public void testComplete() throws IOException { - - Map input = new ListOfKeyValuesDelimitedByBlankLinesToListOfMaps().apply( - Strings2.toStringAndClose(MapToServerInfoTest.class.getResourceAsStream("/servers.txt"))).get(0); - - assertEquals(MAP_TO_DRIVE.apply(input), ONE); - - } - - public static ServerInfo NEW = new ServerInfo.Builder() - .persistent(true) - .uuid("bd98615a-6f74-4d63-ad1e-b13338b9356a") - .cpu(1000) - .bootDeviceIds(ImmutableSet.of("ide:0:0")) - .smp(1) - .mem(512) - .status(ServerStatus.ACTIVE) - .started(new Date(1292695612)) - .user("2f6244eb-50bc-4403-847e-f03cc3706a1f") - .name("adriancole.test") - .vnc(new VNC("83.222.249.221", "XXXXXXXX", false)) - .nics(ImmutableSet.of(new NIC.Builder() - .model(Model.E1000) - .block( - ImmutableList.of("tcp/43594", "tcp/5902", "udp/5060", "tcp/5900", "tcp/5901", "tcp/21", "tcp/22", - "tcp/23", "tcp/25", "tcp/110", "tcp/143", "tcp/43595")).build())) - .devices( - ImmutableMap.of("ide:0:0", - new IDEDevice.Builder(0, 0).uuid("403c9a86-0aab-4e47-aa95-e9768021c4c1").build() - - )) - .metrics( - new ServerMetrics.Builder().driveMetrics(ImmutableMap.of("ide:0:0", new DriveMetrics.Builder().build())) - .build()).build(); - - public void testNew() throws IOException { - - Map input = new ListOfKeyValuesDelimitedByBlankLinesToListOfMaps().apply( - Strings2.toStringAndClose(MapToServerInfoTest.class.getResourceAsStream("/new_server.txt"))).get(0); - - assertEquals(MAP_TO_DRIVE.apply(input), NEW); - - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToVLANInfoTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToVLANInfoTest.java deleted file mode 100644 index 5285e0e5d3..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/MapToVLANInfoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Map; - -import org.jclouds.cloudsigma.domain.VLANInfo; -import org.jclouds.util.Strings2; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class MapToVLANInfoTest { - public static VLANInfo ONE = new VLANInfo.Builder()// - .uuid("6e2d1f6a-03c8-422b-bc8e-d744612cf46a")// - .name("My VLAN1").user("f2e19d5c-eaa1-44e5-94aa-dc194594bd7b").build(); - private static final MapToVLANInfo MAP_TO_VLAN = new MapToVLANInfo(); - - public void testEmptyMapReturnsNull() { - assertEquals(MAP_TO_VLAN.apply(ImmutableMap. of()), null); - } - - public void test() throws IOException { - - Map input = new ListOfKeyValuesDelimitedByBlankLinesToListOfMaps().apply( - Strings2.toStringAndClose(MapToVLANInfoTest.class.getResourceAsStream("/vlan.txt"))).get(0); - - assertEquals(MAP_TO_VLAN.apply(input), ONE); - - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ParseOsFamilyVersion64BitFromImageNameTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ParseOsFamilyVersion64BitFromImageNameTest.java deleted file mode 100644 index a6a3cd5f36..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ParseOsFamilyVersion64BitFromImageNameTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static com.google.common.collect.Iterables.transform; -import static com.google.common.collect.Lists.newArrayList; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Map; -import java.util.Map.Entry; - -import org.jclouds.cloudsigma.compute.functions.ParseOsFamilyVersion64BitFromImageName; -import org.jclouds.compute.config.BaseComputeServiceContextModule; -import org.jclouds.compute.domain.OsFamilyVersion64Bit; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.json.Json; -import org.jclouds.json.config.GsonModule; -import org.jclouds.json.internal.GsonWrapper; -import org.jclouds.util.Strings2; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.gson.Gson; -import com.google.inject.Guice; -import com.google.inject.TypeLiteral; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class ParseOsFamilyVersion64BitFromImageNameTest { - Json json = new GsonWrapper(new Gson()); - - @DataProvider(name = "data") - public Object[][] createData() throws IOException { - InputStream is = ParseOsFamilyVersion64BitFromImageNameTest.class.getResourceAsStream("/osmatches.json"); - Map values = json.fromJson(Strings2.toStringAndClose(is), - new TypeLiteral>() { - }.getType()); - - return newArrayList( - transform(values.entrySet(), new Function, Object[]>() { - - @Override - public Object[] apply(Entry input) { - return new Object[] { input.getKey(), input.getValue() }; - } - - })).toArray(new Object[][] {}); - } - - ParseOsFamilyVersion64BitFromImageName parser = new ParseOsFamilyVersion64BitFromImageName(new BaseComputeServiceContextModule() { - }.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice.createInjector(new GsonModule()) - .getInstance(Json.class))); - - @Test(dataProvider = "data") - public void test(String input, OsFamilyVersion64Bit expected) { - assertEquals(parser.apply(input), expected); - } -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ServerToMapTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ServerToMapTest.java deleted file mode 100644 index bf11c47407..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/ServerToMapTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.cloudsigma.domain.IDEDevice; -import org.jclouds.cloudsigma.domain.Model; -import org.jclouds.cloudsigma.domain.NIC; -import org.jclouds.cloudsigma.domain.Server; -import org.jclouds.cloudsigma.domain.VNC; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class ServerToMapTest { - - private static final ServerToMap SERVER_TO_MAP = new ServerToMap(); - - public void testBasics() { - assertEquals( - SERVER_TO_MAP.apply(new Server.Builder() - .name("TestServer") - .cpu(2000) - .mem(1024) - .devices( - ImmutableMap.of("ide:0:0", - new IDEDevice.Builder(0, 0).uuid("08c92dd5-70a0-4f51-83d2-835919d254df").build())) - .bootDeviceIds(ImmutableSet.of("ide:0:0")).nics(ImmutableSet.of(new NIC.Builder().model(Model.E1000). - - build())).vnc(new VNC(null, "XXXXXXXX", false)).build()), - ImmutableMap - .builder() - .putAll(ImmutableMap.of("name", "TestServer", "cpu", "2000", "smp", "auto", "mem", "1024")) - .putAll( - ImmutableMap.of("persistent", "false", "boot", "ide:0:0", "ide:0:0", - "08c92dd5-70a0-4f51-83d2-835919d254df")) - .putAll( - ImmutableMap.of("ide:0:0:media", "disk", "nic:0:model", "e1000", "vnc:ip", "auto", - "vnc:password", "XXXXXXXX")).build()); - } - -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/SplitNewlinesTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/SplitNewlinesTest.java deleted file mode 100644 index cf18f19f30..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/functions/SplitNewlinesTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.functions; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.util.Set; - -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSortedSet; -import com.google.inject.Guice; - -/** - * Tests behavior of {@code NewlineDelimitedStringHandler} - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class SplitNewlinesTest { - - static Function> createParser() { - return Guice.createInjector().getInstance(SplitNewlines.class); - } - - public void test() { - InputStream is = SplitNewlinesTest.class.getResourceAsStream("/uuids.txt"); - Set list = createParser().apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build()); - assertEquals(list, ImmutableSortedSet.of("7e8ab721-81c9-4cb9-a651-4cafbfe1501c", - "ea6a8fdb-dab3-4d06-86c2-41a5835e6ed9", "74744450-d338-4087-b3b8-59b505110a57")); - } - -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/handlers/CloudSigmaErrorHandlerTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/handlers/CloudSigmaErrorHandlerTest.java deleted file mode 100644 index 8692d7e48d..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/handlers/CloudSigmaErrorHandlerTest.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.handlers; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.reportMatcher; -import static org.easymock.EasyMock.verify; - -import java.net.URI; - -import org.easymock.IArgumentMatcher; -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ResourceNotFoundException; -import org.testng.annotations.Test; - -import com.google.inject.Guice; - -/** - * - * @author Adrian Cole - */ -@Test(groups = { "unit" }) -public class CloudSigmaErrorHandlerTest { - - @Test - public void test400MakesIllegalArgumentException() { - assertCodeMakes("GET", URI.create("https://cloudsigma.com/foo"), 400, "", "Bad Request", - IllegalArgumentException.class); - } - - @Test - public void test400MakesResourceNotFoundExceptionOnInfo() { - assertCodeMakes("GET", URI.create("https://cloudsigma.com/foo/info"), 400, "", "", - ResourceNotFoundException.class); - } - - @Test - public void test400MakesResourceNotFoundExceptionOnMessageNotFound() { - assertCodeMakes( - "GET", - URI.create("https://cloudsigma.com/foo"), - 400, - "", - "errors:system Drive 8f9b42b1-26de-49ad-a3fd-d4fa06524339 could not be found. Please re-validate your entry.", - ResourceNotFoundException.class); - } - - @Test - public void test401MakesAuthorizationException() { - assertCodeMakes("GET", URI.create("https://cloudsigma.com/foo"), 401, "", "Unauthorized", - AuthorizationException.class); - } - - @Test - public void test404MakesResourceNotFoundException() { - assertCodeMakes("GET", URI.create("https://cloudsigma.com/foo"), 404, "", "Not Found", - ResourceNotFoundException.class); - } - - @Test - public void test405MakesIllegalArgumentException() { - assertCodeMakes("GET", URI.create("https://cloudsigma.com/foo"), 405, "", "Method Not Allowed", - IllegalArgumentException.class); - } - - @Test - public void test409MakesIllegalStateException() { - assertCodeMakes("GET", URI.create("https://cloudsigma.com/foo"), 409, "", "Conflict", - IllegalStateException.class); - } - - private void assertCodeMakes(String method, URI uri, int statusCode, String message, String content, - Class expected) { - assertCodeMakes(method, uri, statusCode, message, "text/xml", content, expected); - } - - private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType, - String content, Class expected) { - - CloudSigmaErrorHandler function = Guice.createInjector().getInstance(CloudSigmaErrorHandler.class); - - HttpCommand command = createMock(HttpCommand.class); - HttpRequest request = HttpRequest.builder().method(method).endpoint(uri).build(); - HttpResponse response = HttpResponse.builder().statusCode(statusCode).message(message).payload(content).build(); - response.getPayload().getContentMetadata().setContentType(contentType); - - expect(command.getCurrentRequest()).andReturn(request).atLeastOnce(); - command.setException(classEq(expected)); - - replay(command); - - function.handleError(command, response); - - verify(command); - } - - public static Exception classEq(final Class in) { - reportMatcher(new IArgumentMatcher() { - - @Override - public void appendTo(StringBuffer buffer) { - buffer.append("classEq("); - buffer.append(in); - buffer.append(")"); - } - - @Override - public boolean matches(Object arg) { - return arg.getClass() == in; - } - - }); - return null; - } - -} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/options/CloneDriveOptionsTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/options/CloneDriveOptionsTest.java deleted file mode 100644 index 763d0724c2..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/options/CloneDriveOptionsTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.options; - -import static org.jclouds.cloudsigma.options.CloneDriveOptions.Builder.affinity; -import static org.jclouds.cloudsigma.options.CloneDriveOptions.Builder.size; -import static org.jclouds.cloudsigma.options.CloneDriveOptions.Builder.tags; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import org.jclouds.cloudsigma.domain.AffinityType; -import org.testng.annotations.Test; - -/** - * Tests possible uses of CloneDriveOptions and CloneDriveOptions.Builder.* - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class CloneDriveOptionsTest { - - @Test - public void testNullSize() { - CloneDriveOptions options = new CloneDriveOptions(); - assertNull(options.getOptions().get("size")); - } - - @Test - public void testSize() { - CloneDriveOptions options = new CloneDriveOptions().size(1024); - assertEquals(options.getOptions().get("size"), "1024"); - } - - @Test - public void testSizeStatic() { - CloneDriveOptions options = size(1024); - assertEquals(options.getOptions().get("size"), "1024"); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testSizeNegative() { - size(-1); - } - - @Test - public void testNullTags() { - CloneDriveOptions options = new CloneDriveOptions(); - assertNull(options.getOptions().get("tags")); - } - - @Test - public void testTags() { - CloneDriveOptions options = new CloneDriveOptions().tags("foo", "bar", "baz"); - assertEquals(options.getOptions().get("tags"), "foo bar baz"); - } - - @Test - public void testTagsStatic() { - CloneDriveOptions options = tags("foo", "bar", "baz"); - assertEquals(options.getOptions().get("tags"), "foo bar baz"); - } - - @Test - public void testHddAffinity() { - CloneDriveOptions options = new CloneDriveOptions().affinity(AffinityType.HDD); - assertNull(options.getOptions().get("tags")); - } - - @Test - public void testHddAffinityStatic() { - CloneDriveOptions options = affinity(AffinityType.HDD); - assertNull(options.getOptions().get("tags")); - } - - @Test - public void testSsdAffinity() { - CloneDriveOptions options = new CloneDriveOptions().affinity(AffinityType.SSD); - assertEquals(options.getOptions().get("tags"), "affinity:ssd"); - } - - @Test - public void testSsdAffinityStatic() { - CloneDriveOptions options = affinity(AffinityType.SSD); - assertEquals(options.getOptions().get("tags"), "affinity:ssd"); - } - - @Test - public void testHddAffinityBeforeTags() { - CloneDriveOptions options = new CloneDriveOptions().affinity(AffinityType.HDD); - options.tags("foo", "bar", "baz"); - assertEquals(options.getOptions().get("tags"), "foo bar baz"); - } - - @Test - public void testSsdAffinityBeforeTags() { - CloneDriveOptions options = new CloneDriveOptions().affinity(AffinityType.SSD); - options.tags("foo", "bar", "baz"); - assertEquals(options.getOptions().get("tags"), "foo bar baz affinity:ssd"); - } - - @Test - public void testHddAffinityAfterTags() { - CloneDriveOptions options = new CloneDriveOptions().tags("foo", "bar", "baz"); - options.affinity(AffinityType.HDD); - assertEquals(options.getOptions().get("tags"), "foo bar baz"); - } - - @Test - public void testSsdAffinityAfterTags() { - CloneDriveOptions options = new CloneDriveOptions().tags("foo", "bar", "baz"); - options.affinity(AffinityType.SSD); - assertEquals(options.getOptions().get("tags"), "foo bar baz affinity:ssd"); - } - -} diff --git a/apis/cloudsigma/src/test/resources/create_drive.txt b/apis/cloudsigma/src/test/resources/create_drive.txt deleted file mode 100644 index 44ce187567..0000000000 --- a/apis/cloudsigma/src/test/resources/create_drive.txt +++ /dev/null @@ -1,5 +0,0 @@ -name Ubuntu 10.10 Server Edition Linux 64bit Preinstalled System -size 8589934592 -claim:type shared -readers ffffffff-ffff-ffff-ffff-ffffffffffff -use tag1 tag2 \ No newline at end of file diff --git a/apis/cloudsigma/src/test/resources/create_server.txt b/apis/cloudsigma/src/test/resources/create_server.txt deleted file mode 100644 index 474d4d7ce1..0000000000 --- a/apis/cloudsigma/src/test/resources/create_server.txt +++ /dev/null @@ -1,11 +0,0 @@ -name TestServer -cpu 2000 -smp auto -mem 1024 -persistent false -boot ide:0:0 -ide:0:0 08c92dd5-70a0-4f51-83d2-835919d254df -ide:0:0:media disk -nic:0:model e1000 -vnc:ip auto -vnc:password XXXXXXXX \ No newline at end of file diff --git a/apis/cloudsigma/src/test/resources/drive.txt b/apis/cloudsigma/src/test/resources/drive.txt deleted file mode 100644 index 149c823e86..0000000000 --- a/apis/cloudsigma/src/test/resources/drive.txt +++ /dev/null @@ -1,27 +0,0 @@ -status active -use networking security gateway -name Ubuntu 10.10 Server Edition Linux 64bit Preinstalled System -bits 64 -url http://www.ubuntu.com -read:bytes 4096 -user 58ca3c1f-7629-4771-9b71-863f40153ba4 -encryption:cipher aes-xts-plain -encryption:key ba6c2a4897072e9f25920ed73bd522e9c10d89f30a215158cccf8d0f654ac643 -description The Ubuntu Linux distribution brings the spirit of Ubuntu to the software world. -drive b8171d28-755a-4271-b891-7998871a160e -install_notes first line\n\n -os linux -write:bytes 8589938688 -claim:type shared -claimed 00109617-2c6b-424b-9cfa-5b572c17bafe:guest:692cd1c7-a863-4a22-8170-fc6e6feb68af:ide:0:0 00031836-a624-4b22-bc7d-41ff8977087b:guest:a1414360-7c24-4730-8c97-180bf7775a71:ide:0:0 0002c6df-a1d2-4d1d-96f0-f95405a28183:guest:386f1cc7-affc-49c1-82a5-2f8e412170e4:ide:0:0 00031836-a624-4b22-bc7d-41ff8977087b:guest:17b076be-430d-4a76-9df3-b9896fec82a5:ide:0:0 000663ee-9fb6-4461-90f6-01327a4aff07:guest:f83b519f-feab-42cf-859c-f61495681ada:ide:0:1 -drive_type installcd,livecd -autoexpanding false -tags foo bar baz -readers ffffffff-ffff-ffff-ffff-ffffffffffff -read:requests 1 -free true -type disk -write:requests 2097153 -size 8589934592 -user:foo bar -user:baz raz \ No newline at end of file diff --git a/apis/cloudsigma/src/test/resources/drive_data.txt b/apis/cloudsigma/src/test/resources/drive_data.txt deleted file mode 100644 index 74d7679ce6..0000000000 --- a/apis/cloudsigma/src/test/resources/drive_data.txt +++ /dev/null @@ -1,6 +0,0 @@ -name Ubuntu 10.10 Server Edition Linux 64bit Preinstalled System -size 8589934592 -claim:type shared -tags foo bar baz -readers ffffffff-ffff-ffff-ffff-ffffffffffff -use tag1 tag2 \ No newline at end of file diff --git a/apis/cloudsigma/src/test/resources/log4j.xml b/apis/cloudsigma/src/test/resources/log4j.xml deleted file mode 100644 index 63810d3ca0..0000000000 --- a/apis/cloudsigma/src/test/resources/log4j.xml +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apis/cloudsigma/src/test/resources/new_server.txt b/apis/cloudsigma/src/test/resources/new_server.txt deleted file mode 100644 index 1dfbad99eb..0000000000 --- a/apis/cloudsigma/src/test/resources/new_server.txt +++ /dev/null @@ -1,24 +0,0 @@ -ide:0:0:write:requests 0 -boot ide:0:0 -vnc:password XXXXXXXX -ide:0:0 403c9a86-0aab-4e47-aa95-e9768021c4c1 -ide:0:0:read:requests 0 -ide:0:0:read:bytes 0 -vnc:ip 83.222.249.221 -tx:packets 0 -tx 0 -rx 0 -smp 1 -mem 512 -nic:0:model e1000 -status active -started 1292695612 -rx:packets 0 -user 2f6244eb-50bc-4403-847e-f03cc3706a1f -ide:0:0:media disk -name adriancole.test -persistent true -nic:0:block tcp/43594 tcp/5902 udp/5060 tcp/5900 tcp/5901 tcp/21 tcp/22 tcp/23 tcp/25 tcp/110 tcp/143 tcp/43595 -server bd98615a-6f74-4d63-ad1e-b13338b9356a -ide:0:0:write:bytes 0 -cpu 1000 \ No newline at end of file diff --git a/apis/cloudsigma/src/test/resources/osmatches.json b/apis/cloudsigma/src/test/resources/osmatches.json deleted file mode 100644 index 7b0b1fadda..0000000000 --- a/apis/cloudsigma/src/test/resources/osmatches.json +++ /dev/null @@ -1,174 +0,0 @@ -{ - "Ubuntu-10.04-20110917 pub": { - "family": "UBUNTU", - "version": "10.04", - "is64Bit": true - }, - - "Ubuntu-11.04-20110917 pub": { - "family": "UBUNTU", - "version": "11.04", - "is64Bit": true - }, - - "Centos-6.0-20110917 pub": { - "family": "CENTOS", - "version": "6.0", - "is64Bit": true - }, - - "Centos-5.6-20110917 pub": { - "family": "CENTOS", - "version": "5.6", - "is64Bit": true - }, - - "Ubuntu 10.04.1 LTS Desktop Edition 32bit Preinstalled System": { - "family": "UBUNTU", - "version": "10.04", - "is64Bit": false - }, - - "Ubuntu 10.04 Server Edition Linux 64bit with Plesk": { - "family": "UBUNTU", - "version": "10.04", - "is64Bit": true - }, - - "CentOS 5.5 Linux 64bit Preinstalled System": { - "family": "CENTOS", - "version": "5.5", - "is64Bit": true - }, - - "Windows Server Standard 2008 R2 64bit English": { - "family": "WINDOWS", - "version": "2008 R2", - "is64Bit": true - }, - - "Ubuntu 10.04 Server Edition Linux 64bit": { - "family": "UBUNTU", - "version": "10.04", - "is64Bit": true - }, - - "Windows Server 2008 Standard 32bit English": { - "family": "WINDOWS", - "version": "2008", - "is64Bit": false - }, - - "Windows Server 2008 Standard 32bit English pub": { - "family": "WINDOWS", - "version": "2008", - "is64Bit": false - }, - - - "Fedora 14 Linux 64bit Preinstalled System": { - "family": "FEDORA", - "version": "", - "is64Bit": true - }, - - "CentOS 5.5 Linux 64bit Preinstalled System with AppFirst Monitoring pub": { - "family": "CENTOS", - "version": "5.5", - "is64Bit": true - }, - - - "Ubuntu 10.10 Server Edition LAMP Linux 64bit Preinstalled System": { - "family": "UBUNTU", - "version": "10.10", - "is64Bit": true - }, - - "Ubuntu 10.10 Server Edition Linux 64bit Preinstalled System": { - "family": "UBUNTU", - "version": "10.10", - "is64Bit": true - }, - - "Windows Server Web 2008 R2 64bit English": { - "family": "WINDOWS", - "version": "2008 R2", - "is64Bit": true - }, - - - "SQL Server Standard 2008 R2 - Windows Server Standard 2008 R2 - 64bit English": { - "family": "WINDOWS", - "version": "2008 R2", - "is64Bit": true - }, - - - "Ubuntu 10.10 Desktop Edition 64bit Preinstalled System": { - "family": "UBUNTU", - "version": "10.10", - "is64Bit": true - }, - - "Ubuntu 10.04 Desktop Edition Linux 64bit Preinstalled System": { - "family": "UBUNTU", - "version": "10.04", - "is64Bit": true - }, - - "Debian 5.0 Preinstalled": { - "family": "DEBIAN", - "version": "5.0", - "is64Bit": true - }, - - "pfSense 2.0 BETA4-20101127-031119 Preinstalled System": { - "family": "UNRECOGNIZED", - "version": null, - "is64Bit": true - }, - - "FreeBSD 8.1 Preinstalled Base System": { - "family": "FREEBSD", - "version": "", - "is64Bit": true - }, - - "CentOS 5.5 Linux 64bit Preinstalled System with AppFirst Monitoring": { - "family": "CENTOS", - "version": "5.5", - "is64Bit": true - }, - - "Fedora 13 Linux 64bit Preinstalled System": { - "family": "FEDORA", - "version": "", - "is64Bit": true - }, - - "Windows Server 2003 Standard 32bit English": { - "family": "WINDOWS", - "version": "2003", - "is64Bit": false - }, - - "Windows Server 2003 Standard 64bit English": { - "family": "WINDOWS", - "version": "2003", - "is64Bit": true - }, - - "Debian 5.0 Preinstalled without X": { - "family": "DEBIAN", - "version": "5.0", - "is64Bit": true - }, - - "Debian 6.0 No X Minimal Linux 64bit Preinstalled System": { - "family": "DEBIAN", - "version": "6.0", - "is64Bit": true - } - -} \ No newline at end of file diff --git a/apis/cloudsigma/src/test/resources/profile.txt b/apis/cloudsigma/src/test/resources/profile.txt deleted file mode 100644 index dd71ea4406..0000000000 --- a/apis/cloudsigma/src/test/resources/profile.txt +++ /dev/null @@ -1,28 +0,0 @@ -uuid 58ca3c1f-7629-4771-9b71-863f40153ba4 -email adrian@jclouds.org -salutation -first_name Adrian -last_name Cole -nick_name jclouds -title Mr -company Cloud Conscious, LLC. -vat -country US -town 1200 Fulton St. #609 -language en -currency USD -address 1200 Fulton St. #609 -postcode 1200 Fulton St. #609 -phone 4153180253 -job_title -location -facebook -twitter -xing -linkedin -website -signature -ftp_disabled false -api_disabled false -api_https_only false -type regular \ No newline at end of file diff --git a/apis/cloudsigma/src/test/resources/servers.txt b/apis/cloudsigma/src/test/resources/servers.txt deleted file mode 100644 index a3d1ff1b46..0000000000 --- a/apis/cloudsigma/src/test/resources/servers.txt +++ /dev/null @@ -1,40 +0,0 @@ -ide:0:0:write:requests 3698 -boot ide:0:0 -vnc:password HfHzVmLT -ide:0:0 4af85ed3-0caa-4736-8a26-a33d7de0a122 -ide:0:0:read:requests 11154 -ide:0:0:read:bytes 45686784 -vnc:ip 46.20.114.124 -tx:packets 31 -tx 2550 -rx 455530 -smp 1 -mem 1024 -nic:0:model e1000 -status active -started 1291493868 -rx:packets 7583 -user 2f6244eb-50bc-4403-847e-f03cc3706a1f -name jo -persistent true -nic:0:block tcp/43594 tcp/5902 udp/5060 tcp/5900 tcp/5901 tcp/21 tcp/22 tcp/23 tcp/25 tcp/110 tcp/143 tcp/43595 -server f8bee9cd-8e4b-4a05-8593-1314e3bfe49b -nic:0:dhcp 46.20.114.124 -ide:0:0:write:bytes 15147008 -cpu 2000 - -status stopped -name Demo -mem 1024 -boot ide:0:0 -vnc:password HWbjvrg2 -persistent true -server 0f962616-2071-4173-be79-7dd084271edf -smp auto -nic:0:dhcp auto -user 2f6244eb-50bc-4403-847e-f03cc3706a1f -nic:0:model e1000 -vnc:ip auto -ide:0:0 853bb98a-4fff-4c2f-a265-97c363f19ea5 -cpu 2000 -ide:0:0:media cdrom diff --git a/apis/cloudsigma/src/test/resources/uuids.txt b/apis/cloudsigma/src/test/resources/uuids.txt deleted file mode 100644 index 092a4f8d6d..0000000000 --- a/apis/cloudsigma/src/test/resources/uuids.txt +++ /dev/null @@ -1,3 +0,0 @@ -7e8ab721-81c9-4cb9-a651-4cafbfe1501c -ea6a8fdb-dab3-4d06-86c2-41a5835e6ed9 -74744450-d338-4087-b3b8-59b505110a57 diff --git a/apis/cloudsigma/src/test/resources/vlan.txt b/apis/cloudsigma/src/test/resources/vlan.txt deleted file mode 100644 index f98a1344fc..0000000000 --- a/apis/cloudsigma/src/test/resources/vlan.txt +++ /dev/null @@ -1,4 +0,0 @@ -resource 6e2d1f6a-03c8-422b-bc8e-d744612cf46a -type vlan -user f2e19d5c-eaa1-44e5-94aa-dc194594bd7b -name My VLAN1 \ No newline at end of file diff --git a/apis/pom.xml b/apis/pom.xml index 6ad53d6283..e374d04298 100644 --- a/apis/pom.xml +++ b/apis/pom.xml @@ -31,7 +31,6 @@ jclouds apis project cloudwatch - cloudsigma cloudstack filesystem byon diff --git a/providers/cloudsigma-lvs/pom.xml b/providers/cloudsigma-lvs/pom.xml deleted file mode 100644 index 773008648e..0000000000 --- a/providers/cloudsigma-lvs/pom.xml +++ /dev/null @@ -1,125 +0,0 @@ - - - - 4.0.0 - - org.apache.jclouds - jclouds-project - 1.7.4-SNAPSHOT - ../../project/pom.xml - - org.apache.jclouds.provider - cloudsigma-lvs - jclouds CloudSigma provider - ComputeService binding to the CloudSigma datacenter in SuperNAP Las Vegas - bundle - - - https://api.lvs.cloudsigma.com - 1.0 - - FIXME - FIXME - - org.jclouds.cloudsigma*;version="${project.version}" - - org.jclouds.compute.internal;version="${project.version}", - org.jclouds.rest.internal;version="${project.version}", - org.jclouds*;version="${project.version}", - * - - - - - - org.apache.jclouds.api - cloudsigma - ${project.version} - - - org.apache.jclouds.api - cloudsigma - ${project.version} - test-jar - test - - - org.apache.jclouds - jclouds-core - ${project.version} - test-jar - test - - - org.apache.jclouds - jclouds-compute - ${project.version} - test-jar - test - - - org.apache.jclouds.driver - jclouds-log4j - ${project.version} - test - - - org.apache.jclouds.driver - jclouds-sshj - ${project.version} - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.cloudsigma-lvs.endpoint} - ${test.cloudsigma-lvs.api-version} - ${test.cloudsigma-lvs.build-version} - ${test.cloudsigma-lvs.identity} - ${test.cloudsigma-lvs.credential} - ${test.cloudsigma-lvs.template} - - - - - - - - - - - - diff --git a/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java b/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java deleted file mode 100644 index aa9b97ebba..0000000000 --- a/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.providers.internal.BaseProviderMetadata; - -/** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for CloudSigma Las Vegas. - - * - * @author Adrian Cole - */ -public class CloudSigmaLasVegasProviderMetadata extends BaseProviderMetadata { - - public static Builder builder() { - return new Builder(); - } - - @Override - public Builder toBuilder() { - return builder().fromProviderMetadata(this); - } - - public CloudSigmaLasVegasProviderMetadata() { - super(builder()); - } - - public CloudSigmaLasVegasProviderMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = new Properties(); - return properties; - } - - public static class Builder - extends - BaseProviderMetadata.Builder { - - protected Builder() { - id("cloudsigma-lvs") - .name("CloudSigma Las Vegas") - .apiMetadata(new CloudSigmaApiMetadata()) - .homepage(URI.create("http://www.cloudsigma.com/en/our-cloud/features")) - .console(URI.create("https://gui.lvs.cloudsigma.com/")) - .iso3166Codes("US-NV") - .endpoint("https://api.lvs.cloudsigma.com") - .defaultProperties(CloudSigmaLasVegasProviderMetadata.defaultProperties()); - } - - @Override - public CloudSigmaLasVegasProviderMetadata build() { - return new CloudSigmaLasVegasProviderMetadata(this); - } - - @Override - public Builder fromProviderMetadata( - ProviderMetadata in) { - super.fromProviderMetadata(in); - return this; - } - - } -} diff --git a/providers/cloudsigma-lvs/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/cloudsigma-lvs/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata deleted file mode 100644 index 8f7f34db10..0000000000 --- a/providers/cloudsigma-lvs/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.cloudsigma.CloudSigmaLasVegasProviderMetadata diff --git a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/CloudSigmaLasVegasLondonClientLiveTest.java b/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/CloudSigmaLasVegasLondonClientLiveTest.java deleted file mode 100644 index aeefaf5bb4..0000000000 --- a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/CloudSigmaLasVegasLondonClientLiveTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma; - -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true) -public class CloudSigmaLasVegasLondonClientLiveTest extends CloudSigmaClientLiveTest { - public CloudSigmaLasVegasLondonClientLiveTest() { - provider = "cloudsigma-lvs"; - } -} diff --git a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderTest.java b/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderTest.java deleted file mode 100644 index 22adc5d87c..0000000000 --- a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma; - -import org.jclouds.providers.internal.BaseProviderMetadataTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "CloudSigmaLasVegasProviderTest") -public class CloudSigmaLasVegasProviderTest extends BaseProviderMetadataTest { - - public CloudSigmaLasVegasProviderTest() { - super(new CloudSigmaLasVegasProviderMetadata(), new CloudSigmaApiMetadata()); - } -} diff --git a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasComputeServiceLiveTest.java b/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasComputeServiceLiveTest.java deleted file mode 100644 index affe922cc1..0000000000 --- a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasComputeServiceLiveTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.compute; - -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "CloudSigmaLasVegasComputeServiceLiveTest") -public class CloudSigmaLasVegasComputeServiceLiveTest extends CloudSigmaComputeServiceLiveTest { - - public CloudSigmaLasVegasComputeServiceLiveTest() { - provider = "cloudsigma-lvs"; - } - -} diff --git a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java b/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java deleted file mode 100644 index f85f9612c6..0000000000 --- a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.compute; - -import static org.jclouds.compute.util.ComputeServiceUtils.getCores; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Set; - -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.OsFamilyVersion64Bit; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", testName = "CloudSigmaLasVegasTemplateBuilderLiveTest") -public class CloudSigmaLasVegasTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { - - public CloudSigmaLasVegasTemplateBuilderLiveTest() { - provider = "cloudsigma-lvs"; - } - - @Override - protected Predicate defineUnsupportedOperatingSystems() { - return Predicates.not(new Predicate() { - @Override - public boolean apply(OsFamilyVersion64Bit input) { - switch (input.family) { - case UBUNTU: - return (ImmutableSet.of("11.04", "10.10").contains(input.version) && input.is64Bit) - || (input.version.equals("11.10") && !input.is64Bit) || input.version.equals("") - || input.version.equals("10.04") || input.version.equals("12.04"); - case SOLARIS: - return (input.version.equals("") || input.version.equals("10")) && input.is64Bit; - case DEBIAN: - return input.version.equals("") || (input.version.equals("5.0") && !input.is64Bit) - || (input.version.equals("6.0") && input.is64Bit); - case CENTOS: - return (input.version.equals("") || input.version.equals("5.5") || input.version.equals("5.7") || input.version - .equals("6.0")) && input.is64Bit; - case WINDOWS: - return input.version.equals("2008") || input.version.equals("2003") || input.version.equals(""); - default: - return false; - } - } - - }); - } - - @Override - public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = view.getComputeService().templateBuilder().build(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.04"); - assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getId(), "6aab1938-71b3-4252-ac1c-a3cb17c284ab"); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); - assertEquals(defaultTemplate.getImage().getDefaultCredentials().identity, "root"); - assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); - } - - @Override - protected Set getIso3166Codes() { - return ImmutableSet. of("US-NV"); - } -} diff --git a/providers/cloudsigma-zrh/pom.xml b/providers/cloudsigma-zrh/pom.xml deleted file mode 100644 index b22d4217a5..0000000000 --- a/providers/cloudsigma-zrh/pom.xml +++ /dev/null @@ -1,126 +0,0 @@ - - - - 4.0.0 - - org.apache.jclouds - jclouds-project - 1.7.4-SNAPSHOT - ../../project/pom.xml - - org.apache.jclouds.provider - cloudsigma-zrh - jclouds CloudSigma provider - ComputeService binding to the CloudSigma datacenter in Zürich - bundle - - - https://api.zrh.cloudsigma.com - 1.0 - - FIXME - FIXME - - org.jclouds.cloudsigma*;version="${project.version}" - - org.jclouds.compute.internal;version="${project.version}", - org.jclouds.rest.internal;version="${project.version}", - org.jclouds*;version="${project.version}", - * - - - - - - org.apache.jclouds.api - cloudsigma - ${project.version} - - - org.apache.jclouds.api - cloudsigma - ${project.version} - test-jar - test - - - org.apache.jclouds - jclouds-core - ${project.version} - test-jar - test - - - org.apache.jclouds - jclouds-compute - ${project.version} - test-jar - test - - - org.apache.jclouds.driver - jclouds-log4j - ${project.version} - test - - - org.apache.jclouds.driver - jclouds-sshj - ${project.version} - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.cloudsigma-zrh.endpoint} - ${test.cloudsigma-zrh.api-version} - ${test.cloudsigma-zrh.build-version} - ${test.cloudsigma-zrh.identity} - ${test.cloudsigma-zrh.credential} - ${test.cloudsigma-zrh.template} - - - - - - - - - - - - - diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java deleted file mode 100644 index 4c016833c9..0000000000 --- a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.providers.internal.BaseProviderMetadata; - -/** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for CloudSigma Zurich. - - * - * @author Adrian Cole - */ -public class CloudSigmaZurichProviderMetadata extends BaseProviderMetadata { - - public static Builder builder() { - return new Builder(); - } - - @Override - public Builder toBuilder() { - return builder().fromProviderMetadata(this); - } - - public CloudSigmaZurichProviderMetadata() { - super(builder()); - } - - public CloudSigmaZurichProviderMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = new Properties(); - return properties; - } - - public static class Builder - extends - BaseProviderMetadata.Builder { - - protected Builder() { - id("cloudsigma-zrh") - .name("CloudSigma Zurich") - .apiMetadata(new CloudSigmaApiMetadata()) - .homepage(URI.create("http://www.cloudsigma.com/en/our-cloud/features")) - .console(URI.create("https://gui.zrh.cloudsigma.com/")) - .iso3166Codes("CH-ZH") - .endpoint("https://api.zrh.cloudsigma.com") - .defaultProperties(CloudSigmaZurichProviderMetadata.defaultProperties()); - } - - @Override - public CloudSigmaZurichProviderMetadata build() { - return new CloudSigmaZurichProviderMetadata(this); - } - - @Override - public Builder fromProviderMetadata( - ProviderMetadata in) { - super.fromProviderMetadata(in); - return this; - } - - } -} diff --git a/providers/cloudsigma-zrh/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/cloudsigma-zrh/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata deleted file mode 100644 index 8a1ef553b4..0000000000 --- a/providers/cloudsigma-zrh/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.cloudsigma.CloudSigmaZurichProviderMetadata diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichClientLiveTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichClientLiveTest.java deleted file mode 100644 index ccd92d2b13..0000000000 --- a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichClientLiveTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma; - -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "CloudSigmaZurichClientLiveTest") -public class CloudSigmaZurichClientLiveTest extends CloudSigmaClientLiveTest { - public CloudSigmaZurichClientLiveTest() { - provider = "cloudsigma-zrh"; - } -} diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderTest.java deleted file mode 100644 index 6e70a68efc..0000000000 --- a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma; - -import org.jclouds.providers.internal.BaseProviderMetadataTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "CloudSigmaZurichProviderTest") -public class CloudSigmaZurichProviderTest extends BaseProviderMetadataTest { - - public CloudSigmaZurichProviderTest() { - super(new CloudSigmaZurichProviderMetadata(), new CloudSigmaApiMetadata()); - } -} diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichComputeServiceLiveTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichComputeServiceLiveTest.java deleted file mode 100644 index 1382beaae7..0000000000 --- a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichComputeServiceLiveTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.compute; - -import static com.google.common.collect.Iterables.contains; -import static com.google.common.collect.Iterables.get; -import static org.jclouds.cloudsigma.compute.options.CloudSigmaTemplateOptions.Builder.diskDriveAffinity; -import static org.jclouds.compute.predicates.NodePredicates.inGroup; -import static org.testng.Assert.assertTrue; - -import java.util.Set; - -import org.jclouds.cloudsigma.CloudSigmaApi; -import org.jclouds.cloudsigma.compute.options.CloudSigmaTemplateOptions; -import org.jclouds.cloudsigma.domain.AffinityType; -import org.jclouds.cloudsigma.domain.Device; -import org.jclouds.cloudsigma.domain.DriveInfo; -import org.jclouds.cloudsigma.domain.ServerInfo; -import org.jclouds.compute.RunNodesException; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.TemplateBuilder; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "CloudSigmaZurichComputeServiceLiveTest") -public class CloudSigmaZurichComputeServiceLiveTest extends CloudSigmaComputeServiceLiveTest { - - public CloudSigmaZurichComputeServiceLiveTest() { - provider = "cloudsigma-zrh"; - } - - @Test - public void testStartNodeWithSSD() throws RunNodesException { - String group = this.group + "-ssd"; - - TemplateBuilder builder = client.templateBuilder(); - assert builder instanceof CloudSigmaTemplateBuilderImpl; - - Template template = builder.options(diskDriveAffinity(AffinityType.SSD)).build(); - assert template.getOptions() instanceof CloudSigmaTemplateOptions; - - try { - Set nodes = client.createNodesInGroup(group, 1, template); - NodeMetadata node = get(nodes, 0); - - CloudSigmaApi api = client.getContext().unwrapApi(CloudSigmaApi.class); - - // Note: I wanted to use node.getHardware().getVolumes() but there is no - // way to go from a Volume to a DriveInfo - - ServerInfo serverInfo = api.getServerInfo(node.getId()); - Device rootDevice = get(serverInfo.getDevices().values(), 0); - DriveInfo driveInfo = api.getDriveInfo(rootDevice.getDriveUuid()); - assertTrue(contains(driveInfo.getTags(), "affinity:ssd")); - - } finally { - client.destroyNodesMatching(inGroup(group)); - } - } - -} diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java deleted file mode 100644 index 7d9038e2f3..0000000000 --- a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudsigma.compute; - -import static org.jclouds.compute.util.ComputeServiceUtils.getCores; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Set; - -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.OsFamilyVersion64Bit; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.ImmutableSet; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "CloudSigmaZurichTemplateBuilderLiveTest") -public class CloudSigmaZurichTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { - - public CloudSigmaZurichTemplateBuilderLiveTest() { - provider = "cloudsigma-zrh"; - } - - @Override - protected Predicate defineUnsupportedOperatingSystems() { - return Predicates.not(new Predicate() { - @Override - public boolean apply(OsFamilyVersion64Bit input) { - switch (input.family) { - case UBUNTU: - return input.version.equals("") || input.version.equals("10.04") - || (input.version.equals("10.10") && input.is64Bit) - || (input.version.equals("11.04") && !input.is64Bit); - case DEBIAN: - return (input.version.equals("") || input.version.equals("6.0")) && input.is64Bit; - case CENTOS: - return (input.version.equals("") || input.version.equals("5.7")) && input.is64Bit; - case WINDOWS: - return input.version.equals("") || input.version.matches("200[38]") - || (input.version.equals("2008 R2") && input.is64Bit); - default: - return false; - } - } - - }); - } - - @Override - public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = view.getComputeService().templateBuilder().build(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), ""); - assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getId(), "c9df6b90-420c-4c46-b7f2-8d9e99929a09"); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); - assertEquals(defaultTemplate.getImage().getDefaultCredentials().identity, "root"); - assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); - } - - @Override - protected Set getIso3166Codes() { - return ImmutableSet. of("CH-ZH"); - } -} diff --git a/providers/pom.xml b/providers/pom.xml index d8e3ed38d7..726a28f3e4 100644 --- a/providers/pom.xml +++ b/providers/pom.xml @@ -31,8 +31,6 @@ jclouds providers project gogrid - cloudsigma-zrh - cloudsigma-lvs azureblob aws-s3 aws-ec2