This repository has been archived by the owner on Mar 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1464 from aplowe/master
cloudstack: adding support for create volume from a custom disk offering
- Loading branch information
Showing
5 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VolumeClientExpectTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* Licensed to jclouds, Inc. (jclouds) under one or more | ||
* contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. jclouds 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.cloudstack.features; | ||
|
||
import org.jclouds.cloudstack.CloudStackApiMetadata; | ||
import org.jclouds.cloudstack.CloudStackContext; | ||
import org.jclouds.cloudstack.domain.AsyncCreateResponse; | ||
import org.jclouds.cloudstack.internal.BaseCloudStackExpectTest; | ||
import org.jclouds.http.HttpRequest; | ||
import org.jclouds.http.HttpResponse; | ||
import org.testng.annotations.Test; | ||
|
||
import java.net.URI; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.cert.CertificateException; | ||
|
||
import static org.testng.Assert.assertNotNull; | ||
|
||
/** | ||
* Test the CloudStack VolumeClient | ||
* | ||
* @author Adam Lowe | ||
*/ | ||
@Test(groups = "unit", testName = "VolumeClientExpectTest") | ||
public class VolumeClientExpectTest extends BaseCloudStackExpectTest<VolumeClient> { | ||
|
||
public void testCreateVolumeFromCustomDiskOffering() throws NoSuchAlgorithmException, CertificateException { | ||
VolumeClient client = requestSendsResponse( | ||
HttpRequest.builder() | ||
.method("GET") | ||
.endpoint( | ||
URI.create("http://localhost:8080/client/api?response=json&" + | ||
"command=createVolume&name=VolumeClientExpectTest-jclouds-volume&diskofferingid=0473f5dd-bca5-4af4-a9b6-db9e8a88a2f6&zoneid=6f9a2921-b22a-4149-8b71-6ffc275a2177&size=1&apiKey=identity&signature=Y4%2BmdvhS/jlKRNSJ3nQqrjwg1CY%3D")) | ||
.addHeader("Accept", "application/json") | ||
.build(), | ||
HttpResponse.builder() | ||
.statusCode(200) | ||
.payload(payloadFromResource("/queryasyncjobresultresponse-createvolume.json")) | ||
.build()); | ||
|
||
AsyncCreateResponse response = client.createVolumeFromCustomDiskOfferingInZone("VolumeClientExpectTest-jclouds-volume", "0473f5dd-bca5-4af4-a9b6-db9e8a88a2f6", "6f9a2921-b22a-4149-8b71-6ffc275a2177", 1); | ||
assertNotNull(response); | ||
} | ||
|
||
@Override | ||
protected VolumeClient clientFrom(CloudStackContext context) { | ||
return context.unwrap(CloudStackApiMetadata.CONTEXT_TOKEN).getApi().getVolumeClient(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
apis/cloudstack/src/test/resources/queryasyncjobresultresponse-createvolume.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"queryasyncjobresultresponse" : | ||
{"accountid":"43e3d66f-c8a3-43b2-a3d0-3bbc2416da14", | ||
"userid":"99458e63-725b-48ec-aedc-f8ccc11f5231", | ||
"cmd":"com.cloud.api.commands.CreateVolumeCmd", | ||
"jobstatus":1, | ||
"jobprocstatus":0, | ||
"jobresultcode":0, | ||
"jobresulttype":"object", | ||
"jobresult":{ | ||
"volume":{ | ||
"id":"f947c7b3-e079-4e7d-aacc-1509d1ae387a", | ||
"name":"VolumeClientExpectTest-jclouds-volume", | ||
"zoneid":"6f9a2921-b22a-4149-8b71-6ffc275a2177", | ||
"zonename":"Basic1", | ||
"type":"DATADISK", | ||
"size":1073741824, | ||
"created":"2013-02-05T13:41:14+0200", | ||
"state":"Allocated", | ||
"account":"admin", | ||
"domainid":"99f4159b-c698-4bd9-b8c5-5ac462f101eb", | ||
"domain":"ROOT", | ||
"storagetype":"shared", | ||
"hypervisor":"None", | ||
"diskofferingid":"0473f5dd-bca5-4af4-a9b6-db9e8a88a2f6", | ||
"diskofferingname":"Custom", | ||
"diskofferingdisplaytext":"Custom Disk", | ||
"storage":"none","destroyed":false, | ||
"isextractable":true, | ||
"tags":[] | ||
} | ||
}, | ||
"created":"2013-02-05T13:41:14+0200", | ||
"jobid":"4ec82395-365a-4dad-8bd7-238c4f388702" | ||
} | ||
} |