mirror of https://github.com/apache/cloudstack.git
More changes to the test client
This commit is contained in:
parent
3eb97d7d02
commit
62bee3ddf3
|
|
@ -1,9 +1,15 @@
|
|||
hostname=localhost
|
||||
apikey=p62of2UV0INfl9Jyg-vl90nAnhPMg9vioiHc5QBcx4DyeUl_OZLEWxMVzqtdzmLlgIoMz5yNmrSUy0z1bdIOHA
|
||||
secretkey=UZeggpLS1n5XqzQ-CDGJt04Vk8i3kwF-Q7FGy0whGf_awy_rWTqt4Ui3cEJNEPLu5gt9m34kZNVOl5wptauaEg
|
||||
account=admin
|
||||
domainId=1
|
||||
serviceOfferingId=1
|
||||
networkId=204
|
||||
templateId=5
|
||||
zoneId==1
|
||||
#hostname=localhost
|
||||
#apikey=p62of2UV0INfl9Jyg-vl90nAnhPMg9vioiHc5QBcx4DyeUl_OZLEWxMVzqtdzmLlgIoMz5yNmrSUy0z1bdIOHA
|
||||
#secretkey=UZeggpLS1n5XqzQ-CDGJt04Vk8i3kwF-Q7FGy0whGf_awy_rWTqt4Ui3cEJNEPLu5gt9m34kZNVOl5wptauaEg
|
||||
#serviceOfferingId=1
|
||||
#networkId=204
|
||||
#templateId=5
|
||||
#zoneId==1
|
||||
|
||||
hostname=72.52.126.25
|
||||
apikey=efol8YgakHjAgEm44U354nvG_jjSRxPfH3ervj-pzHlN29eeQHR4lW9t75OCYWZPVqhrX0rrA9CVC8CQ3lEFbA
|
||||
secretkey=6XNjKKOTAZb95JWp33FbycdVlClE5o2mjTTuGHoVLbo5-mZIxGPzbEO04tvbNttM4G1cPAiZg95vnk5L31NCYQ
|
||||
serviceOfferingId=b251c4b0-3146-4e34-bd87-478bf67cd026
|
||||
networkId=34e2c654-abde-45bf-adff-0417e6082900
|
||||
templateId=e31b8b01-2858-4765-b462-707f46ea0422
|
||||
zoneId=1
|
||||
|
|
@ -5,79 +5,21 @@ import java.io.InputStream;
|
|||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import com.cloud.test.demo.response.ApiConstants;
|
||||
import com.cloud.test.demo.response.CloudStackIpAddress;
|
||||
import com.cloud.test.demo.response.CloudStackPortForwardingRule;
|
||||
import com.cloud.test.demo.response.CloudStackUserVm;
|
||||
import com.cloud.test.demo.response.CloudStackServiceOffering;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
public class CloudStackHttpClient {
|
||||
|
||||
|
||||
/*public static void main (String[] args) {
|
||||
|
||||
try {
|
||||
//list serviceOfferings
|
||||
String requestUrl = "http://localhost:8096/client/api?command=listServiceOfferings&issystem=false&response=json";
|
||||
List<CloudStackServiceOffering> offerings = execute(requestUrl, "listserviceofferingsresponse", "serviceoffering", new TypeToken<List<CloudStackServiceOffering>>() {}.getType());
|
||||
|
||||
for(CloudStackServiceOffering offering : offerings){
|
||||
System.out.println("id: "+ offering.getId());
|
||||
System.out.println("name: "+ offering.getName());
|
||||
}
|
||||
|
||||
//list VMs
|
||||
requestUrl = "http://localhost:8096/client/api?command=listVirtualMachines&listAll=true&response=json";
|
||||
List<CloudStackUserVm> vmList = execute(requestUrl, "listvirtualmachinesresponse", "virtualmachine", new TypeToken<List<CloudStackUserVm>>() {}.getType() );
|
||||
|
||||
for(CloudStackUserVm vm : vmList){
|
||||
System.out.println("id: "+ vm.getId());
|
||||
System.out.println("state: "+ vm.getState());
|
||||
}
|
||||
/*
|
||||
//list PF rules
|
||||
requestUrl = "http://localhost:8096/client/api?command=listPortForwardingRules&response=json";
|
||||
List<CloudStackPortForwardingRule> pfList = execute(requestUrl, "listportforwardingrulesresponse", "portforwardingrule", new TypeToken<List<CloudStackPortForwardingRule>>() {}.getType() );
|
||||
|
||||
for(CloudStackPortForwardingRule pf : pfList){
|
||||
System.out.println("id: "+ pf.getId());
|
||||
}
|
||||
|
||||
//list IP
|
||||
requestUrl = "http://localhost:8096/client/api?command=listPublicIpAddresses&response=json";
|
||||
List<CloudStackIpAddress> ipList = execute(requestUrl, "listpublicipaddressesresponse", "publicipaddress", new TypeToken<List<CloudStackIpAddress>>() {}.getType() );
|
||||
|
||||
for(CloudStackIpAddress ipaddress : ipList){
|
||||
System.out.println("id: "+ ipaddress.getId());
|
||||
}
|
||||
|
||||
requestUrl = "http://localhost:8096/client/api?command=deployVirtualMachine&response=json&serviceofferingid=afd925fa-995a-41d2-97f2-5ff475393946&zoneid=97356452-8f0d-429a-8b10-c8694d8a194c&templateid=83ad7959-c0ee-4625-b235-f9a66c0826d8&size=0";
|
||||
CloudStackUserVm vm = execute(requestUrl, true, "deployvirtualmachineresponse", "virtualmachine", CloudStackUserVm.class);
|
||||
System.out.println("id: "+ vm.getId());
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
public <T> List<T> execute(String request, String responseName, String responseObjName, Type collectionType){
|
||||
JsonElement jsonElement;
|
||||
try {
|
||||
jsonElement = execute(request);
|
||||
JsonElement jsonElement = execute(request);
|
||||
|
||||
JsonElement response = getChildElement(jsonElement,responseName);
|
||||
JsonElement responseObj = getChildElement(response,responseObjName);
|
||||
|
|
@ -87,14 +29,9 @@ public class CloudStackHttpClient {
|
|||
}
|
||||
|
||||
if(responseObj.isJsonArray()){
|
||||
JsonArray responseObjElementArray = responseObj.getAsJsonArray();
|
||||
for(JsonElement responseObjElement : responseObjElementArray){
|
||||
System.out.println(responseObjName + ":" + responseObjElement.toString());
|
||||
}
|
||||
return (new Gson()).fromJson(responseObjElementArray, collectionType);
|
||||
return (new Gson()).fromJson(responseObj.getAsJsonArray(), collectionType);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return (new Gson()).fromJson(new JsonArray(), collectionType);
|
||||
}
|
||||
|
|
@ -112,8 +49,8 @@ public class CloudStackHttpClient {
|
|||
String responseName, String responseObjName, Class<T> responseClz){
|
||||
|
||||
assert(responseName != null);
|
||||
long _pollTimeoutMs = 600000;
|
||||
long _pollIntervalMs = 2000; // 1 second polling interval
|
||||
long _pollTimeoutMs = 600000;//10 mins timeout
|
||||
long _pollIntervalMs = 2000; // 1 second polling interval
|
||||
|
||||
try{
|
||||
JsonElement jsonElement = execute(request);
|
||||
|
|
@ -178,7 +115,6 @@ public class CloudStackHttpClient {
|
|||
return (T)(new Gson()).fromJson(responseObj, responseClz);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
|
@ -188,14 +124,14 @@ public class CloudStackHttpClient {
|
|||
JsonParser parser = new JsonParser();
|
||||
URL url = new URL(request);
|
||||
|
||||
System.out.println("Cloud API call + [" + url.toString() + "]");
|
||||
//System.out.println("Cloud API call + [" + url.toString() + "]");
|
||||
|
||||
URLConnection connect = url.openConnection();
|
||||
|
||||
int statusCode;
|
||||
statusCode = ((HttpURLConnection)connect).getResponseCode();
|
||||
if(statusCode >= 400) {
|
||||
System.out.println("Cloud API call + [" + url.toString() + "] failed with status code: " + statusCode);
|
||||
//System.out.println("Cloud API call + [" + url.toString() + "] failed with status code: " + statusCode);
|
||||
throw new IOException("CloudStack API call HTTP response error, HTTP status code: " + statusCode);
|
||||
}
|
||||
|
||||
|
|
@ -207,7 +143,7 @@ public class CloudStackHttpClient {
|
|||
throw new IOException("CloudStack API call error : invalid JSON response");
|
||||
}
|
||||
|
||||
System.out.println("Cloud API call + [" + url.toString() + "] returned: " + jsonElement.toString());
|
||||
//System.out.println("Cloud API call + [" + url.toString() + "] returned: " + jsonElement.toString());
|
||||
return jsonElement;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,14 +17,23 @@ import java.io.FileInputStream;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.cloud.test.demo.response.CloudStackPortForwardingRule;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import com.cloud.sample.Base64;
|
||||
import com.cloud.test.demo.response.CloudStackIpAddress;
|
||||
import com.cloud.test.demo.response.CloudStackPortForwardingRule;
|
||||
import com.cloud.test.demo.response.CloudStackUserVm;
|
||||
import com.cloud.test.utils.UtilsForTest;
|
||||
import com.cloud.utils.PropertiesUtil;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.trilead.ssh2.ChannelCondition;
|
||||
|
|
@ -37,25 +46,28 @@ import com.trilead.ssh2.Session;
|
|||
public class Demo {
|
||||
private static HashMap<String, Boolean> _apiCommands = new HashMap<String, Boolean>();
|
||||
private static Properties properties = new Properties();
|
||||
private static String _host = null;
|
||||
|
||||
public static void main(String[] args){
|
||||
//read properties files
|
||||
readCommandsType();
|
||||
readDeployConfig();
|
||||
readProperties();
|
||||
_host = "http://" + properties.getProperty("hostname") + "/client/api?";
|
||||
//create the deployment
|
||||
String publicIp = createDeployment();
|
||||
//setup httpd on the user vms
|
||||
//setupHttpd(publicIp, "password");
|
||||
//setup web server on user vm
|
||||
setupHttpd(publicIp, "password");
|
||||
|
||||
//return web access url
|
||||
System.out.println("\nURL is " + "http://" + publicIp + "/cloudcom-faq.html");
|
||||
}
|
||||
|
||||
private static void readCommandsType() {
|
||||
private static void readProperties() {
|
||||
Properties preProcessedCommands = new Properties();
|
||||
String configFile = "../conf/demo/commandstype.properties";
|
||||
File commandsFile = PropertiesUtil.findConfigFile(configFile);
|
||||
String filePath = "../conf/demo/commandstype.properties";
|
||||
File configFile = PropertiesUtil.findConfigFile(filePath);
|
||||
try {
|
||||
if (commandsFile != null) {
|
||||
preProcessedCommands.load(new FileInputStream(commandsFile));
|
||||
if (configFile != null) {
|
||||
preProcessedCommands.load(new FileInputStream(configFile));
|
||||
for (Object key : preProcessedCommands.keySet()) {
|
||||
String strKey = (String)key;
|
||||
String asyncParams = (String)preProcessedCommands.getProperty(strKey);
|
||||
|
|
@ -69,33 +81,32 @@ public class Demo {
|
|||
} catch (FileNotFoundException fnfex) {
|
||||
System.exit(1);
|
||||
} catch (IOException ex) {
|
||||
System.out.println("ERROR: Error reading properites file " + configFile);
|
||||
System.out.println("ERROR: Error reading properites file " + filePath);
|
||||
System.exit(1);
|
||||
} finally {
|
||||
if (commandsFile == null) {
|
||||
System.out.println("ERROR: Unable to find properites file " + configFile);
|
||||
if (configFile == null) {
|
||||
System.out.println("ERROR: Unable to find properites file " + filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void readDeployConfig() {
|
||||
String configFile = "../conf/demo/setup.properties";
|
||||
File commandsFile = PropertiesUtil.findConfigFile(configFile);
|
||||
|
||||
filePath = "../conf/demo/setup.properties";
|
||||
configFile = PropertiesUtil.findConfigFile(filePath);
|
||||
try {
|
||||
if (commandsFile != null) {
|
||||
properties.load(new FileInputStream(commandsFile));
|
||||
if (configFile != null) {
|
||||
properties.load(new FileInputStream(configFile));
|
||||
}
|
||||
} catch (FileNotFoundException fnfex) {
|
||||
System.exit(1);
|
||||
} catch (IOException ex) {
|
||||
System.out.println("ERROR: Error reading properites file " + configFile);
|
||||
System.out.println("ERROR: Error reading properites file " + filePath);
|
||||
System.exit(1);
|
||||
} finally {
|
||||
if (commandsFile == null) {
|
||||
System.out.println("ERROR: Unable to find properites file " + configFile);
|
||||
if (configFile == null) {
|
||||
System.out.println("ERROR: Unable to find properites file " + filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void setupHttpd(String host, String password) {
|
||||
if (host == null) {
|
||||
|
|
@ -110,7 +121,7 @@ public class Demo {
|
|||
|
||||
try {
|
||||
System.out.println("Sleeping for 1 min before trying to ssh into linux host ");
|
||||
//Thread.sleep(60000);
|
||||
Thread.sleep(60000);
|
||||
System.out.println("Attempting to SSH into linux host " + host);
|
||||
|
||||
Connection conn = new Connection(host);
|
||||
|
|
@ -179,58 +190,155 @@ public class Demo {
|
|||
}
|
||||
|
||||
public static String createDeployment() {
|
||||
CloudStackHttpClient client = new CloudStackHttpClient();
|
||||
boolean success = true;
|
||||
|
||||
//1) deployVm
|
||||
String urlToSign = "command=deployVirtualMachine&serviceOfferingId=" + properties.getProperty("serviceOfferingId") +
|
||||
"&networkId=" + properties.getProperty("networkId") +
|
||||
"&templateId=" + properties.getProperty("templateId") + "&zoneId=" + properties.getProperty("zoneId");
|
||||
String url = UtilsForTest.signUrl(urlToSign, properties.getProperty("apikey"),
|
||||
"&networkIds=" + properties.getProperty("networkId") +
|
||||
"&templateId=" + properties.getProperty("templateId") + "&zoneId=" + properties.getProperty("zoneId") +
|
||||
"&response=json";
|
||||
String url = signUrl(urlToSign, properties.getProperty("apikey"),
|
||||
properties.getProperty("secretkey"));
|
||||
String requestUrl = "http://" + properties.getProperty("hostname") + ":8080/client/api?" + url;
|
||||
String requestUrl = _host + url;
|
||||
System.out.println(requestUrl);
|
||||
|
||||
CloudStackHttpClient client = new CloudStackHttpClient();
|
||||
|
||||
CloudStackUserVm vm = client.execute(requestUrl, _apiCommands.get("deployVirtualMachine"), "deployvirtualmachineresponse", "virtualmachine", CloudStackUserVm.class);
|
||||
CloudStackUserVm vm = client.execute(requestUrl, _apiCommands.get("deployVirtualMachine"), "deployvirtualmachineresponse",
|
||||
"virtualmachine", CloudStackUserVm.class);
|
||||
|
||||
String vmId = null;
|
||||
if(vm != null){
|
||||
vmId = vm.getId();
|
||||
System.out.println("Successfully deployed vm with id " + vmId);
|
||||
} else {
|
||||
System.out.println("ERROR: failed to deploy the vm");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
|
||||
//2) List public IP address - source nat
|
||||
urlToSign = "command=listPublicIpAddresses&zoneId=" + properties.getProperty("zoneId");
|
||||
url = UtilsForTest.signUrl(urlToSign, properties.getProperty("apikey"),
|
||||
urlToSign = "command=listPublicIpAddresses&zoneId=" + properties.getProperty("zoneId") + "&response=json";
|
||||
url = signUrl(urlToSign, properties.getProperty("apikey"),
|
||||
properties.getProperty("secretkey"));
|
||||
requestUrl = "http://" + properties.getProperty("hostname") + ":8080/client/api?" + url;
|
||||
System.out.println(requestUrl);
|
||||
requestUrl = _host + url;
|
||||
|
||||
List<CloudStackIpAddress> ipList = client.execute(requestUrl,"listpublicipaddressesresponse", "publicipaddress", new TypeToken<List<CloudStackIpAddress>>(){}.getType());
|
||||
List<CloudStackIpAddress> ipList = client.execute(requestUrl,"listpublicipaddressesresponse", "publicipaddress",
|
||||
new TypeToken<List<CloudStackIpAddress>>(){}.getType());
|
||||
|
||||
if (ipList.isEmpty()) {
|
||||
System.out.println("ERROR: account doesn't own any public ip address");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
CloudStackIpAddress ip = ipList.get(0);
|
||||
String ipId = ip.getId();
|
||||
String ipAddress = ip.getIpAddress();
|
||||
|
||||
long ipId=67;
|
||||
String ip = "10.223.153.76";
|
||||
|
||||
//3) create portForwarding rules for port 22 and 80
|
||||
urlToSign = "command=createPortForwardingRule&privateport=22&publicport=22&protocol=tcp&ipaddressid=" + ipId +
|
||||
"&virtualmachineid=" + vmId;
|
||||
url = UtilsForTest.signUrl(urlToSign, properties.getProperty("apikey"),
|
||||
"&virtualmachineid=" + vmId + "&response=json";
|
||||
url = signUrl(urlToSign, properties.getProperty("apikey"),
|
||||
properties.getProperty("secretkey"));
|
||||
requestUrl = "http://" + properties.getProperty("hostname") + ":8080/client/api?" + url;
|
||||
System.out.println(requestUrl);
|
||||
CloudStackPortForwardingRule pfrule1 = client.execute(requestUrl, _apiCommands.get("createPortForwardingRule"), "createportforwardingruleresponse", "portforwardingrule", CloudStackPortForwardingRule.class);
|
||||
requestUrl = _host + url;
|
||||
CloudStackPortForwardingRule pfrule1 = client.execute(requestUrl, _apiCommands.get("createPortForwardingRule"),
|
||||
"createportforwardingruleresponse", "portforwardingrule", CloudStackPortForwardingRule.class);
|
||||
|
||||
if (pfrule1 == null) {
|
||||
System.out.println("ERROR: failed to create pf rule for the port 22");
|
||||
System.exit(1);
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
urlToSign = "command=createPortForwardingRule&privateport=80&publicport=80&protocol=tcp&ipaddressid=" + ipId +
|
||||
"&virtualmachineid=" + vmId;
|
||||
url = UtilsForTest.signUrl(urlToSign, properties.getProperty("apikey"),
|
||||
"&virtualmachineid=" + vmId + "&response=json";
|
||||
url = signUrl(urlToSign, properties.getProperty("apikey"),
|
||||
properties.getProperty("secretkey"));
|
||||
|
||||
requestUrl = "http://" + properties.getProperty("hostname") + ":8080/client/api?" + url;
|
||||
System.out.println(requestUrl);
|
||||
CloudStackPortForwardingRule pfrule2 = client.execute(requestUrl, _apiCommands.get("createPortForwardingRule"), "createportforwardingruleresponse", "portforwardingrule", CloudStackPortForwardingRule.class);
|
||||
requestUrl = _host + url;
|
||||
CloudStackPortForwardingRule pfrule2 = client.execute(requestUrl, _apiCommands.get("createPortForwardingRule"),
|
||||
"createportforwardingruleresponse", "portforwardingrule", CloudStackPortForwardingRule.class);
|
||||
|
||||
if (pfrule1 == null) {
|
||||
System.out.println("ERROR: failed to create pf rule for the port 80");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
return ip;
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
|
||||
public static String generateSignature(String request, String key) {
|
||||
try {
|
||||
Mac mac = Mac.getInstance("HmacSHA1");
|
||||
SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(),
|
||||
"HmacSHA1");
|
||||
mac.init(keySpec);
|
||||
mac.update(request.getBytes());
|
||||
byte[] encryptedBytes = mac.doFinal();
|
||||
//System.out.println("HmacSHA1 hash: " + encryptedBytes);
|
||||
return Base64.encodeBytes(encryptedBytes);
|
||||
} catch (Exception ex) {
|
||||
System.out.println("unable to sign request");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String signUrl(String url, String apiKey, String secretKey) {
|
||||
|
||||
//sorted map (sort by key)
|
||||
TreeMap<String, String> param = new TreeMap<String, String>();
|
||||
|
||||
String temp = "";
|
||||
param.put("apikey", apiKey);
|
||||
|
||||
//1) Parse the URL and put all parameters to sorted map
|
||||
StringTokenizer str1 = new StringTokenizer (url, "&");
|
||||
while(str1.hasMoreTokens()) {
|
||||
String newEl = str1.nextToken();
|
||||
StringTokenizer str2 = new StringTokenizer(newEl, "=");
|
||||
String name = str2.nextToken();
|
||||
String value= str2.nextToken();
|
||||
param.put(name, value);
|
||||
}
|
||||
|
||||
//2) URL encode parameters' values
|
||||
Set<Map.Entry<String, String>> c = param.entrySet();
|
||||
Iterator<Map.Entry<String,String>> it = c.iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<String, String> me = (Map.Entry<String, String>)it.next();
|
||||
String key = (String) me.getKey();
|
||||
String value = (String) me.getValue();
|
||||
try {
|
||||
temp = temp + key + "=" + URLEncoder.encode(value, "UTF-8") + "&";
|
||||
} catch (Exception ex) {
|
||||
System.out.println("Unable to set parameter " + value + " for the command " + param.get("command"));
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
temp = temp.substring(0, temp.length()-1 );
|
||||
|
||||
//3) Lower case the request
|
||||
String requestToSign = temp.toLowerCase();
|
||||
|
||||
//4) Generate the signature
|
||||
String signature = generateSignature(requestToSign, secretKey);
|
||||
|
||||
//5) Encode the signature
|
||||
String encodedSignature = "";
|
||||
try {
|
||||
encodedSignature = URLEncoder.encode(signature, "UTF-8");
|
||||
} catch (Exception ex) {
|
||||
System.out.println(ex);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
//6) append the signature to the url
|
||||
url = temp + "&signature=" + encodedSignature;
|
||||
return url;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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 com.cloud.test.demo.response;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class CloudStackIngressRule {
|
||||
|
||||
@SerializedName(ApiConstants.RULE_ID)
|
||||
private String ruleId;
|
||||
|
||||
@SerializedName(ApiConstants.PROTOCOL)
|
||||
private String protocol;
|
||||
|
||||
@SerializedName(ApiConstants.ICMP_TYPE)
|
||||
private Integer icmpType;
|
||||
|
||||
@SerializedName(ApiConstants.ICMP_CODE)
|
||||
private Integer icmpCode;
|
||||
|
||||
@SerializedName(ApiConstants.START_PORT)
|
||||
private Integer startPort;
|
||||
|
||||
@SerializedName(ApiConstants.END_PORT)
|
||||
private Integer endPort;
|
||||
|
||||
@SerializedName(ApiConstants.SECURITY_GROUP_NAME)
|
||||
private String securityGroupName;
|
||||
|
||||
@SerializedName(ApiConstants.ACCOUNT)
|
||||
private String accountName;
|
||||
|
||||
@SerializedName(ApiConstants.CIDR)
|
||||
private String cidr;
|
||||
|
||||
public CloudStackIngressRule() {
|
||||
}
|
||||
|
||||
public String getRuleId() {
|
||||
return ruleId;
|
||||
}
|
||||
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public Integer getIcmpType() {
|
||||
return icmpType;
|
||||
}
|
||||
|
||||
public Integer getIcmpCode() {
|
||||
return icmpCode;
|
||||
}
|
||||
|
||||
public Integer getStartPort() {
|
||||
return startPort;
|
||||
}
|
||||
|
||||
public Integer getEndPort() {
|
||||
return endPort;
|
||||
}
|
||||
|
||||
public String getSecurityGroupName() {
|
||||
return securityGroupName;
|
||||
}
|
||||
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
public String getCidr() {
|
||||
return cidr;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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 com.cloud.test.demo.response;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class CloudStackNic {
|
||||
|
||||
@SerializedName(ApiConstants.ID)
|
||||
private String id;
|
||||
|
||||
@SerializedName(ApiConstants.BROADCAST_URI)
|
||||
private String broadcastUri;
|
||||
|
||||
@SerializedName(ApiConstants.GATEWAY)
|
||||
private String gateway;
|
||||
|
||||
@SerializedName(ApiConstants.IP_ADDRESS)
|
||||
private String ipaddress;
|
||||
|
||||
@SerializedName(ApiConstants.IS_DEFAULT)
|
||||
private Boolean isDefault;
|
||||
|
||||
@SerializedName(ApiConstants.ISOLATION_URI)
|
||||
private String isolationUri;
|
||||
|
||||
@SerializedName(ApiConstants.MAC_ADDRESS)
|
||||
private String macAddress;
|
||||
|
||||
@SerializedName(ApiConstants.NETMASK)
|
||||
private String netmask;
|
||||
|
||||
@SerializedName(ApiConstants.NETWORK_ID)
|
||||
private String networkid;
|
||||
|
||||
@SerializedName(ApiConstants.TRAFFIC_TYPE)
|
||||
private String trafficType;
|
||||
|
||||
@SerializedName(ApiConstants.TYPE)
|
||||
private String type;
|
||||
|
||||
public CloudStackNic() {
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getNetworkid() {
|
||||
return networkid;
|
||||
}
|
||||
|
||||
public String getNetmask() {
|
||||
return netmask;
|
||||
}
|
||||
|
||||
public String getGateway() {
|
||||
return gateway;
|
||||
}
|
||||
|
||||
public String getIpaddress() {
|
||||
return ipaddress;
|
||||
}
|
||||
|
||||
public String getIsolationUri() {
|
||||
return isolationUri;
|
||||
}
|
||||
|
||||
public String getBroadcastUri() {
|
||||
return broadcastUri;
|
||||
}
|
||||
|
||||
public String getTrafficType() {
|
||||
return trafficType;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Boolean getIsDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the macAddress
|
||||
*/
|
||||
public String getMacAddress() {
|
||||
return macAddress;
|
||||
}
|
||||
}
|
||||
|
|
@ -24,13 +24,13 @@ import com.google.gson.annotations.SerializedName;
|
|||
*/
|
||||
public class CloudStackPortForwardingRule {
|
||||
@SerializedName(ApiConstants.ID)
|
||||
private Long id;
|
||||
private String id;
|
||||
@SerializedName(ApiConstants.CIDR_LIST)
|
||||
private String cidrList;
|
||||
@SerializedName(ApiConstants.IP_ADDRESS)
|
||||
private String ipAddress;
|
||||
@SerializedName(ApiConstants.IP_ADDRESS_ID)
|
||||
private Long ipAddressId;
|
||||
private String ipAddressId;
|
||||
@SerializedName(ApiConstants.PRIVATE_END_PORT)
|
||||
private Long privateEndPort;
|
||||
@SerializedName(ApiConstants.PRIVATE_PORT)
|
||||
|
|
@ -46,7 +46,7 @@ public class CloudStackPortForwardingRule {
|
|||
@SerializedName(ApiConstants.VIRTUAL_MACHINE_DISPLAY_NAME)
|
||||
private String virtualMachineDisplayName;
|
||||
@SerializedName(ApiConstants.VIRTUAL_MACHINE_ID)
|
||||
private Long virtualMachineId;
|
||||
private String virtualMachineId;
|
||||
@SerializedName(ApiConstants.VIRTUAL_MACHINE_NAME)
|
||||
private String virtualMachineName;
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ public class CloudStackPortForwardingRule {
|
|||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public Long getId() {
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ public class CloudStackPortForwardingRule {
|
|||
/**
|
||||
* @return the ipAddressId
|
||||
*/
|
||||
public Long getIpAddressId() {
|
||||
public String getIpAddressId() {
|
||||
return ipAddressId;
|
||||
}
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ public class CloudStackPortForwardingRule {
|
|||
/**
|
||||
* @return the virtualMachineId
|
||||
*/
|
||||
public Long getVirtualMachineId() {
|
||||
public String getVirtualMachineId() {
|
||||
return virtualMachineId;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2011 Citrix Systems, Inc. All rights reserved.
|
||||
*
|
||||
* Licensed 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 com.cloud.test.demo.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class CloudStackSecurityGroup {
|
||||
@SerializedName(ApiConstants.ID)
|
||||
private String id;
|
||||
@SerializedName(ApiConstants.ACCOUNT)
|
||||
private String accountName;
|
||||
@SerializedName(ApiConstants.DESCRIPTION)
|
||||
private String description;
|
||||
@SerializedName(ApiConstants.DOMAIN)
|
||||
private String domainName;
|
||||
@SerializedName(ApiConstants.DOMAIN_ID)
|
||||
private String domainId;
|
||||
@SerializedName(ApiConstants.JOB_ID)
|
||||
private Long jobId;
|
||||
@SerializedName(ApiConstants.JOB_STATUS)
|
||||
private Integer jobStatus;
|
||||
@SerializedName(ApiConstants.NAME)
|
||||
private String name;
|
||||
@SerializedName(ApiConstants.INGRESS_RULE)
|
||||
private List<CloudStackIngressRule> ingressRules;
|
||||
|
||||
|
||||
public CloudStackSecurityGroup() {
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public String getDomainName() {
|
||||
return domainName;
|
||||
}
|
||||
|
||||
public Long getJobId() {
|
||||
return jobId;
|
||||
}
|
||||
|
||||
public Integer getJobStatus() {
|
||||
return jobStatus;
|
||||
}
|
||||
|
||||
public List<CloudStackIngressRule> getIngressRules() {
|
||||
return ingressRules;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,181 +0,0 @@
|
|||
package com.cloud.test.demo.response;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class CloudStackServiceOffering {
|
||||
|
||||
@SerializedName(ApiConstants.ID)
|
||||
private String id;
|
||||
@SerializedName(ApiConstants.CPU_NUMBER)
|
||||
private Long cpuNumber;
|
||||
@SerializedName(ApiConstants.CPU_SPEED)
|
||||
private Long cpuSpeed;
|
||||
@SerializedName(ApiConstants.CREATED)
|
||||
private String created;
|
||||
@SerializedName(ApiConstants.DEFAULT_USE)
|
||||
private Boolean defaultUse;
|
||||
@SerializedName(ApiConstants.DISPLAY_TEXT)
|
||||
private String displayText;
|
||||
@SerializedName(ApiConstants.DOMAIN)
|
||||
private String domain;
|
||||
@SerializedName(ApiConstants.DOMAIN_ID)
|
||||
private String domainId;
|
||||
@SerializedName(ApiConstants.HOST_TAGS)
|
||||
private String hostTags;
|
||||
@SerializedName(ApiConstants.IS_SYSTEM)
|
||||
private Boolean isSystem;
|
||||
@SerializedName(ApiConstants.LIMIT_CPU_USE)
|
||||
private Boolean limitCpuUse;
|
||||
@SerializedName(ApiConstants.MEMORY)
|
||||
private Long memory;
|
||||
@SerializedName(ApiConstants.NAME)
|
||||
private String name;
|
||||
@SerializedName(ApiConstants.OFFER_HA)
|
||||
private Boolean offerHa;
|
||||
@SerializedName(ApiConstants.STORAGE_TYPE)
|
||||
private String storageType;
|
||||
@SerializedName(ApiConstants.SYSTEM_VM_TYPE)
|
||||
private String systemVmType;
|
||||
@SerializedName(ApiConstants.TAGS)
|
||||
private String tags;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public CloudStackServiceOffering() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cpuNumber
|
||||
*/
|
||||
public Long getCpuNumber() {
|
||||
return cpuNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cpuSpeed
|
||||
*/
|
||||
public Long getCpuSpeed() {
|
||||
return cpuSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the created
|
||||
*/
|
||||
public String getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the defaultUse
|
||||
*/
|
||||
public Boolean getDefaultUse() {
|
||||
return defaultUse;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the displayText
|
||||
*/
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the domain
|
||||
*/
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the domainId
|
||||
*/
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public void setDomainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hostTags
|
||||
*/
|
||||
public String getHostTags() {
|
||||
return hostTags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the isSystem
|
||||
*/
|
||||
public Boolean getIsSystem() {
|
||||
return isSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the limitCpuUse
|
||||
*/
|
||||
public Boolean getLimitCpuUse() {
|
||||
return limitCpuUse;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the memory
|
||||
*/
|
||||
public Long getMemory() {
|
||||
return memory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the offerHa
|
||||
*/
|
||||
public Boolean getOfferHa() {
|
||||
return offerHa;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the storageType
|
||||
*/
|
||||
public String getStorageType() {
|
||||
return storageType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the systemVmType
|
||||
*/
|
||||
public String getSystemVmType() {
|
||||
return systemVmType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the tags
|
||||
*/
|
||||
public String getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -15,8 +15,6 @@
|
|||
*/
|
||||
package com.cloud.test.demo.response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class CloudStackUserVm {
|
||||
|
|
@ -98,10 +96,6 @@ public class CloudStackUserVm {
|
|||
private String zoneId;
|
||||
@SerializedName(ApiConstants.ZONE_NAME)
|
||||
private String zoneName;
|
||||
@SerializedName(ApiConstants.NIC)
|
||||
private List<CloudStackNic> nics;
|
||||
@SerializedName(ApiConstants.SECURITY_GROUP)
|
||||
private List<CloudStackSecurityGroup> securityGroupList;
|
||||
|
||||
public CloudStackUserVm() {
|
||||
}
|
||||
|
|
@ -379,19 +373,5 @@ public class CloudStackUserVm {
|
|||
return zoneName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the nics
|
||||
*/
|
||||
public List<CloudStackNic> getNics() {
|
||||
return nics;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the securityGroupList
|
||||
*/
|
||||
public List<CloudStackSecurityGroup> getSecurityGroupList() {
|
||||
return securityGroupList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue