You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ah...@apache.org on 2013/12/12 22:01:04 UTC
[04/48] All Checkstyle problems corrected
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/test/src/com/cloud/test/stress/TestClientWithAPI.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/stress/TestClientWithAPI.java b/test/src/com/cloud/test/stress/TestClientWithAPI.java
index d49cf0b..420bda6 100644
--- a/test/src/com/cloud/test/stress/TestClientWithAPI.java
+++ b/test/src/com/cloud/test/stress/TestClientWithAPI.java
@@ -64,38 +64,38 @@ public class TestClientWithAPI {
private static int numOfUsers = 0;
private static String[] users = null;
private static boolean internet = false;
- private static ThreadLocal<String> _linuxIP = new ThreadLocal<String>();
- private static ThreadLocal<String> _linuxIpId = new ThreadLocal<String>();
- private static ThreadLocal<String> _linuxVmId = new ThreadLocal<String>();
- private static ThreadLocal<String> _linuxPassword = new ThreadLocal<String>();
- private static ThreadLocal<String> _windowsIP = new ThreadLocal<String>();
- private static ThreadLocal<String> _windowsIpId = new ThreadLocal<String>();
- private static ThreadLocal<String> _windowsVmId = new ThreadLocal<String>();
- private static ThreadLocal<String> _secretKey = new ThreadLocal<String>();
- private static ThreadLocal<String> _apiKey = new ThreadLocal<String>();
- private static ThreadLocal<Long> _userId = new ThreadLocal<Long>();
- private static ThreadLocal<Long> _accountId = new ThreadLocal<Long>();
- private static ThreadLocal<String> _account = new ThreadLocal<String>();
- private static ThreadLocal<String> _domainRouterId = new ThreadLocal<String>();
- private static ThreadLocal<String> _pfGroupId = new ThreadLocal<String>();
- private static ThreadLocal<String> _windowsLb = new ThreadLocal<String>();
- private static ThreadLocal<String> _linuxLb = new ThreadLocal<String>();
- private static ThreadLocal<String> _dataVolume = new ThreadLocal<String>();
- private static ThreadLocal<String> _rootVolume = new ThreadLocal<String>();
- private static ThreadLocal<String> _newVolume = new ThreadLocal<String>();
- private static ThreadLocal<String> _snapshot = new ThreadLocal<String>();
- private static ThreadLocal<String> _volumeFromSnapshot = new ThreadLocal<String>();
- private static ThreadLocal<String> _networkId = new ThreadLocal<String>();
- private static ThreadLocal<String> _publicIpId = new ThreadLocal<String>();
- private static ThreadLocal<String> _winipfwdid = new ThreadLocal<String>();
- private static ThreadLocal<String> _linipfwdid = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_linuxIP = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_linuxIpId = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_linuxVmId = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_linuxPassword = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_windowsIP = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_windowsIpId = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_windowsVmId = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_secretKey = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_apiKey = new ThreadLocal<String>();
+ private static ThreadLocal<Long> s_userId = new ThreadLocal<Long>();
+ private static ThreadLocal<Long> s_accountId = new ThreadLocal<Long>();
+ private static ThreadLocal<String> s_account = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_domainRouterId = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_pfGroupId = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_windowsLb = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_linuxLb = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_dataVolume = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_rootVolume = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_newVolume = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_snapshot = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_volumeFromSnapshot = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_networkId = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_publicIpId = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_winipfwdid = new ThreadLocal<String>();
+ private static ThreadLocal<String> s_linipfwdid = new ThreadLocal<String>();
private static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
private static int usageIterator = 1;
private static int numThreads = 1;
private static int wait = 5000;
private static String accountName = null;
private static String zoneId = "1";
- private static String snapshot_test = "no";
+ private static String snapshotTest = "no";
private static String serviceOfferingId = "1";
private static String diskOfferingId = "4";
private static String networkOfferingId = "6";
@@ -168,7 +168,7 @@ public class TestClientWithAPI {
}
if (arg.equals("-snapshot")) {
- snapshot_test = "yes";
+ snapshotTest = "yes";
}
if (arg.equals("-so")) {
@@ -225,7 +225,7 @@ public class TestClientWithAPI {
NDC.push(username);
s_logger.info("Starting test for the user " + username);
- int response = executeDeployment(server, developerServer, username, snapshot_test);
+ int response = executeDeployment(server, developerServer, username, snapshotTest);
boolean success = false;
String reason = null;
@@ -239,22 +239,22 @@ public class TestClientWithAPI {
// can boot up and do a sys prep.
if (accountName == null) {
- s_logger.info("Begin Linux SSH test for account " + _account.get());
- reason = sshTest(_linuxIP.get(), _linuxPassword.get(), snapshot_test);
+ s_logger.info("Begin Linux SSH test for account " + s_account.get());
+ reason = sshTest(s_linuxIP.get(), s_linuxPassword.get(), snapshotTest);
}
if (reason == null) {
- s_logger.info("Linux SSH test successful for account " + _account.get());
- s_logger.info("Begin WindowsSSH test for account " + _account.get());
+ s_logger.info("Linux SSH test successful for account " + s_account.get());
+ s_logger.info("Begin WindowsSSH test for account " + s_account.get());
- reason = sshTest(_linuxIP.get(), _linuxPassword.get(), snapshot_test);
- // reason = sshWinTest(_windowsIP.get());
+ reason = sshTest(s_linuxIP.get(), s_linuxPassword.get(), snapshotTest);
+ // reason = sshWinTest(s_windowsIP.get());
}
// release the linux IP now...
- _linuxIP.set(null);
+ s_linuxIP.set(null);
// release the Windows IP now
- _windowsIP.set(null);
+ s_windowsIP.set(null);
}
// sleep for 3 min before getting the latest network stat
@@ -263,7 +263,7 @@ public class TestClientWithAPI {
// verify that network stat is correct for the user; if it's not - stop all the resources
// for the user
// if ((reason == null) && (getNetworkStat(server) == false) ) {
- // s_logger.error("Stopping all the resources for the account " + _account.get() +
+ // s_logger.error("Stopping all the resources for the account " + s_account.get() +
// " as network stat is incorrect");
// int stopResponseCode = executeStop(
// server, developerServer,
@@ -276,7 +276,7 @@ public class TestClientWithAPI {
// } else
if (reason == null) {
if (internet) {
- s_logger.info("Windows SSH test successful for account " + _account.get());
+ s_logger.info("Windows SSH test successful for account " + s_account.get());
} else {
s_logger.info("deploy test successful....now cleaning up");
if (cleanUp) {
@@ -313,7 +313,7 @@ public class TestClientWithAPI {
} else {
// Just stop but don't destroy the
// VMs/Routers
- s_logger.info("SSH test failed for account " + _account.get() + "with reason '" + reason + "', stopping VMs");
+ s_logger.info("SSH test failed for account " + s_account.get() + "with reason '" + reason + "', stopping VMs");
int stopResponseCode = executeStop(server, developerServer, username, false);
s_logger.info("stop command finished with response code: " + stopResponseCode);
success = false; // since the SSH test
@@ -495,7 +495,7 @@ public class TestClientWithAPI {
}
private static String executeRegistration(String server, String username, String password) throws HttpException, IOException {
- String url = server + "?command=registerUserKeys&id=" + _userId.get().toString();
+ String url = server + "?command=registerUserKeys&id=" + s_userId.get().toString();
s_logger.info("registering: " + username);
String returnValue = null;
HttpClient client = new HttpClient();
@@ -504,7 +504,7 @@ public class TestClientWithAPI {
if (responseCode == 200) {
InputStream is = method.getResponseBodyAsStream();
Map<String, String> requestKeyValues = getSingleValueFromXML(is, new String[] {"apikey", "secretkey"});
- _apiKey.set(requestKeyValues.get("apikey"));
+ s_apiKey.set(requestKeyValues.get("apikey"));
returnValue = requestKeyValues.get("secretkey");
} else {
s_logger.error("registration failed with error code: " + responseCode);
@@ -512,7 +512,7 @@ public class TestClientWithAPI {
return returnValue;
}
- private static Integer executeDeployment(String server, String developerServer, String username, String snapshot_test) throws HttpException, IOException {
+ private static Integer executeDeployment(String server, String developerServer, String username, String snapshotTest) throws HttpException, IOException {
// test steps:
// - create user
// - deploy Windows VM
@@ -545,8 +545,8 @@ public class TestClientWithAPI {
s_logger.info("created account " + username + " with id " + accountIdStr);
if (accountIdStr != null) {
accountId = Long.parseLong(accountIdStr);
- _accountId.set(accountId);
- _account.set(accountValues.get("name"));
+ s_accountId.set(accountId);
+ s_account.set(accountValues.get("name"));
if (accountId == -1) {
s_logger.error("create account (" + username + ") failed to retrieve a valid user id, aborting depolyment test");
return -1;
@@ -571,7 +571,7 @@ public class TestClientWithAPI {
s_logger.info("listed user " + username + " with id " + userIdStr);
if (userIdStr != null) {
userId = Long.parseLong(userIdStr);
- _userId.set(userId);
+ s_userId.set(userId);
if (userId == -1) {
s_logger.error("list user by username " + username + ") failed to retrieve a valid user id, aborting depolyment test");
return -1;
@@ -583,14 +583,14 @@ public class TestClientWithAPI {
return -1;
}
- _secretKey.set(executeRegistration(server, username, username));
+ s_secretKey.set(executeRegistration(server, username, username));
- if (_secretKey.get() == null) {
+ if (s_secretKey.get() == null) {
s_logger.error("FAILED to retrieve secret key during registration, skipping user: " + username);
return -1;
} else {
- s_logger.info("got secret key: " + _secretKey.get());
- s_logger.info("got api key: " + _apiKey.get());
+ s_logger.info("got secret key: " + s_secretKey.get());
+ s_logger.info("got api key: " + s_apiKey.get());
}
// ---------------------------------
@@ -608,7 +608,7 @@ public class TestClientWithAPI {
String networkIdStr = networkValues.get("id");
s_logger.info("Created virtual network with name virtualnetwork-" + encodedUsername + " and id " + networkIdStr);
if (networkIdStr != null) {
- _networkId.set(networkIdStr);
+ s_networkId.set(networkIdStr);
}
} else {
s_logger.error("Create virtual network failed for account " + username + " with error code :" + responseCode +
@@ -629,7 +629,7 @@ public class TestClientWithAPI {
String networkIdStr = networkValues.get("id");
s_logger.info("Created direct network with name directnetwork-" + encodedUsername + " and id " + networkIdStr);
if (networkIdStr != null) {
- _networkId_dir.set(networkIdStr);
+ s_networkId_dir.set(networkIdStr);
}
} else {
s_logger.error("Create direct network failed for account " + username + " with error code :" + responseCode + ", aborting deployment test. The command was sent with url " + url);
@@ -647,13 +647,13 @@ public class TestClientWithAPI {
String encodedZoneId = URLEncoder.encode("" + zoneId, "UTF-8");
String encodedServiceOfferingId = URLEncoder.encode("" + serviceOfferingId, "UTF-8");
String encodedTemplateId = URLEncoder.encode("" + templateId, "UTF-8");
- String encodedApiKey = URLEncoder.encode(_apiKey.get(), "UTF-8");
- String encodedNetworkIds = URLEncoder.encode(_networkId.get() + ",206", "UTF-8");
+ String encodedApiKey = URLEncoder.encode(s_apiKey.get(), "UTF-8");
+ String encodedNetworkIds = URLEncoder.encode(s_networkId.get() + ",206", "UTF-8");
String requestToSign =
"apikey=" + encodedApiKey + "&command=deployVirtualMachine&diskofferingid=" + diskOfferingId + "&networkids=" + encodedNetworkIds +
"&serviceofferingid=" + encodedServiceOfferingId + "&templateid=" + encodedTemplateId + "&zoneid=" + encodedZoneId;
requestToSign = requestToSign.toLowerCase();
- String signature = signRequest(requestToSign, _secretKey.get());
+ String signature = signRequest(requestToSign, s_secretKey.get());
String encodedSignature = URLEncoder.encode(signature, "UTF-8");
url =
developerServer + "?command=deployVirtualMachine" + "&zoneid=" + encodedZoneId + "&serviceofferingid=" + encodedServiceOfferingId + "&diskofferingid=" +
@@ -674,11 +674,11 @@ public class TestClientWithAPI {
s_logger.info("deploy linux vm response code: " + responseCode);
long linuxVMId = Long.parseLong(values.get("id"));
s_logger.info("got linux virtual machine id: " + linuxVMId);
- _linuxVmId.set(values.get("id"));
+ s_linuxVmId.set(values.get("id"));
linuxVMPrivateIP = values.get("ipaddress");
- // _linuxPassword.set(values.get("password"));
- _linuxPassword.set(vmPassword);
- s_logger.info("got linux virtual machine password: " + _linuxPassword.get());
+ // s_linuxPassword.set(values.get("password"));
+ s_linuxPassword.set(vmPassword);
+ s_logger.info("got linux virtual machine password: " + s_linuxPassword.get());
}
} else {
s_logger.error("deploy linux vm failed with error code: " + responseCode + ". Following URL was sent: " + url);
@@ -692,10 +692,10 @@ public class TestClientWithAPI {
// ---------------------------------
String ipAddr = null;
- String encodedApiKey = URLEncoder.encode(_apiKey.get(), "UTF-8");
+ String encodedApiKey = URLEncoder.encode(s_apiKey.get(), "UTF-8");
String requestToSign = "apikey=" + encodedApiKey + "&command=associateIpAddress" + "&zoneid=" + zoneId;
requestToSign = requestToSign.toLowerCase();
- String signature = signRequest(requestToSign, _secretKey.get());
+ String signature = signRequest(requestToSign, s_secretKey.get());
String encodedSignature = URLEncoder.encode(signature, "UTF-8");
url = developerServer + "?command=associateIpAddress" + "&apikey=" + encodedApiKey + "&zoneid=" + zoneId + "&signature=" + encodedSignature;
@@ -715,17 +715,17 @@ public class TestClientWithAPI {
s_logger.info("Associate IP Address response code: " + responseCode);
long publicIpId = Long.parseLong(values.get("id"));
s_logger.info("Associate IP's Id: " + publicIpId);
- _publicIpId.set(values.get("id"));
+ s_publicIpId.set(values.get("id"));
}
} else {
s_logger.error("associate ip address for windows vm failed with error code: " + responseCode + ". Following URL was sent: " + url);
return responseCode;
}
- String encodedPublicIpId = URLEncoder.encode(_publicIpId.get(), "UTF-8");
+ String encodedPublicIpId = URLEncoder.encode(s_publicIpId.get(), "UTF-8");
requestToSign = "apikey=" + encodedApiKey + "&command=listPublicIpAddresses" + "&id=" + encodedPublicIpId;
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
url = developerServer + "?command=listPublicIpAddresses&apikey=" + encodedApiKey + "&id=" + encodedPublicIpId + "&signature=" + encodedSignature;
@@ -740,8 +740,8 @@ public class TestClientWithAPI {
List<String> ipAddressValues = getIPs(is, false);
// List<String> ipAddressVals = getIPs(is, false, true);
if ((ipAddressValues != null) && !ipAddressValues.isEmpty()) {
- _windowsIpId.set(ipAddressValues.get(0));
- _windowsIP.set(ipAddressValues.get(1));
+ s_windowsIpId.set(ipAddressValues.get(0));
+ s_windowsIP.set(ipAddressValues.get(1));
s_logger.info("For Windows, using non-sourceNat IP address ID: " + ipAddressValues.get(0));
s_logger.info("For Windows, using non-sourceNat IP address: " + ipAddressValues.get(1));
}
@@ -756,7 +756,7 @@ public class TestClientWithAPI {
{
requestToSign = "apikey=" + encodedApiKey + "&command=listPublicIpAddresses";
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
url = developerServer + "?command=listPublicIpAddresses&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
@@ -772,8 +772,8 @@ public class TestClientWithAPI {
// is = method.getResponseBodyAsStream();
// List<String> ipAddressVals = getIPs(is, true, true);
if ((ipAddressValues != null) && !ipAddressValues.isEmpty()) {
- _linuxIpId.set(ipAddressValues.get(0));
- _linuxIP.set(ipAddressValues.get(1));
+ s_linuxIpId.set(ipAddressValues.get(0));
+ s_linuxIP.set(ipAddressValues.get(1));
s_logger.info("For linux, using sourceNat IP address ID: " + ipAddressValues.get(0));
s_logger.info("For linux, using sourceNat IP address: " + ipAddressValues.get(1));
}
@@ -786,11 +786,11 @@ public class TestClientWithAPI {
//--------------------------------------------
// Enable Static NAT for the Source NAT Ip
//--------------------------------------------
- String encodedSourceNatPublicIpId = URLEncoder.encode(_linuxIpId.get(), "UTF-8");
+ String encodedSourceNatPublicIpId = URLEncoder.encode(s_linuxIpId.get(), "UTF-8");
/* requestToSign = "apikey=" + encodedApiKey + "&command=enableStaticNat"+"&id=" + encodedSourceNatPublicIpId + "&virtualMachineId=" + encodedVmId;;
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
url = developerServer + "?command=enableStaticNat&apikey=" + encodedApiKey + "&signature=" + encodedSignature + "&id=" + encodedSourceNatPublicIpId + "&virtualMachineId=" + encodedVmId;
@@ -811,13 +811,13 @@ public class TestClientWithAPI {
// -------------------------------------------------------------
// CREATE IP FORWARDING RULE -- Linux VM
// -------------------------------------------------------------
- String encodedVmId = URLEncoder.encode(_linuxVmId.get(), "UTF-8");
- String encodedIpAddress = URLEncoder.encode(_linuxIpId.get(), "UTF-8");
+ String encodedVmId = URLEncoder.encode(s_linuxVmId.get(), "UTF-8");
+ String encodedIpAddress = URLEncoder.encode(s_linuxIpId.get(), "UTF-8");
requestToSign =
"apikey=" + encodedApiKey + "&command=createPortForwardingRule&ipaddressid=" + encodedIpAddress + "&privateport=22&protocol=TCP&publicport=22" +
"&virtualmachineid=" + encodedVmId;
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
url =
@@ -834,7 +834,7 @@ public class TestClientWithAPI {
s_logger.info("Port forwarding rule was assigned successfully to Linux VM");
long ipfwdid = Long.parseLong(values.get("id"));
s_logger.info("got Port Forwarding Rule's Id:" + ipfwdid);
- _linipfwdid.set(values.get("id"));
+ s_linipfwdid.set(values.get("id"));
} else {
s_logger.error("Port forwarding rule creation failed with error code: " + responseCode + ". Following URL was sent: " + url);
@@ -842,11 +842,11 @@ public class TestClientWithAPI {
}
// Create snapshot recurring policy if needed; otherwise create windows vm
- if (snapshot_test.equals("yes")) {
+ if (snapshotTest.equals("yes")) {
// list volumes for linux vm
{
- url = server + "?command=listVolumes&virtualMachineId=" + _linuxVmId.get() + "&type=root";
+ url = server + "?command=listVolumes&virtualMachineId=" + s_linuxVmId.get() + "&type=root";
s_logger.info("Getting rootDisk id of Centos vm");
client = new HttpClient();
method = new GetMethod(url);
@@ -859,7 +859,7 @@ public class TestClientWithAPI {
s_logger.error("Unable to get root volume for linux vm. Followin url was sent: " + url);
}
s_logger.info("Got rootVolume for linux vm with id " + success.get("id"));
- _rootVolume.set(success.get("id"));
+ s_rootVolume.set(success.get("id"));
} else {
s_logger.error("List volumes for linux vm failed with error code: " + responseCode + ". Following URL was sent: " + url);
return responseCode;
@@ -869,7 +869,7 @@ public class TestClientWithAPI {
{
String encodedTimeZone = URLEncoder.encode("America/Los Angeles", "UTF-8");
url =
- server + "?command=createSnapshotPolicy&intervaltype=hourly&schedule=10&maxsnaps=4&volumeid=" + _rootVolume.get() + "&timezone=" +
+ server + "?command=createSnapshotPolicy&intervaltype=hourly&schedule=10&maxsnaps=4&volumeid=" + s_rootVolume.get() + "&timezone=" +
encodedTimeZone;
s_logger.info("Creating recurring snapshot policy for linux vm ROOT disk");
client = new HttpClient();
@@ -893,14 +893,14 @@ public class TestClientWithAPI {
String encodedZoneId = URLEncoder.encode("" + zoneId, "UTF-8");
String encodedServiceOfferingId = URLEncoder.encode("" + serviceOfferingId, "UTF-8");
String encodedTemplateId = URLEncoder.encode("" + templateId, "UTF-8");
- encodedApiKey = URLEncoder.encode(_apiKey.get(), "UTF-8");
- String encodedNetworkIds = URLEncoder.encode(_networkId.get() + ",206", "UTF-8");
+ encodedApiKey = URLEncoder.encode(s_apiKey.get(), "UTF-8");
+ String encodedNetworkIds = URLEncoder.encode(s_networkId.get() + ",206", "UTF-8");
requestToSign =
"apikey=" + encodedApiKey + "&command=deployVirtualMachine&diskofferingid=" + diskOfferingId + "&networkids=" + encodedNetworkIds +
"&serviceofferingid=" + encodedServiceOfferingId + "&templateid=" + encodedTemplateId + "&zoneid=" + encodedZoneId;
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
url =
@@ -923,7 +923,7 @@ public class TestClientWithAPI {
windowsVMPrivateIP = values.get("ipaddress");
long windowsVMId = Long.parseLong(values.get("id"));
s_logger.info("got windows virtual machine id: " + windowsVMId);
- _windowsVmId.set(values.get("id"));
+ s_windowsVmId.set(values.get("id"));
}
} else {
s_logger.error("deploy windows vm failes with error code: " + responseCode + ". Following URL was sent: " + url);
@@ -935,11 +935,11 @@ public class TestClientWithAPI {
// Enable Static NAT for the Non Source NAT Ip
//--------------------------------------------
- encodedVmId = URLEncoder.encode(_windowsVmId.get(), "UTF-8");
- encodedPublicIpId = URLEncoder.encode(_publicIpId.get(), "UTF-8");
+ encodedVmId = URLEncoder.encode(s_windowsVmId.get(), "UTF-8");
+ encodedPublicIpId = URLEncoder.encode(s_publicIpId.get(), "UTF-8");
requestToSign = "apikey=" + encodedApiKey + "&command=enableStaticNat" + "&ipaddressid=" + encodedPublicIpId + "&virtualMachineId=" + encodedVmId;
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
url =
@@ -964,12 +964,12 @@ public class TestClientWithAPI {
// -------------------------------------------------------------
// create port forwarding rule for window vm
- encodedIpAddress = URLEncoder.encode(_windowsIpId.get(), "UTF-8");
- //encodedVmId = URLEncoder.encode(_windowsVmId.get(), "UTF-8");
+ encodedIpAddress = URLEncoder.encode(s_windowsIpId.get(), "UTF-8");
+ //encodedVmId = URLEncoder.encode(s_windowsVmId.get(), "UTF-8");
requestToSign = "apikey=" + encodedApiKey + "&command=createIpForwardingRule&endPort=22&ipaddressid=" + encodedIpAddress + "&protocol=TCP&startPort=22";
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
url =
@@ -986,7 +986,7 @@ public class TestClientWithAPI {
s_logger.info("Port forwarding rule was assigned successfully to Windows VM");
long ipfwdid = Long.parseLong(values.get("id"));
s_logger.info("got Ip Forwarding Rule's Id:" + ipfwdid);
- _winipfwdid.set(values.get("id"));
+ s_winipfwdid.set(values.get("id"));
} else {
s_logger.error("Port forwarding rule creation failed with error code: " + responseCode + ". Following URL was sent: " + url);
return responseCode;
@@ -1004,7 +1004,7 @@ public class TestClientWithAPI {
// -----------------------------
// GET USER
// -----------------------------
- String userId = _userId.get().toString();
+ String userId = s_userId.get().toString();
String encodedUserId = URLEncoder.encode(userId, "UTF-8");
String url = server + "?command=listUsers&id=" + encodedUserId;
s_logger.info("Cleaning up resources for user: " + userId + " with url " + url);
@@ -1048,7 +1048,7 @@ public class TestClientWithAPI {
// Detach existin dataVolume, create a new volume, attach it to the vm
// -----------------------------
{
- url = server + "?command=listVolumes&virtualMachineId=" + _linuxVmId.get() + "&type=dataDisk";
+ url = server + "?command=listVolumes&virtualMachineId=" + s_linuxVmId.get() + "&type=dataDisk";
s_logger.info("Getting dataDisk id of Centos vm");
client = new HttpClient();
method = new GetMethod(url);
@@ -1058,7 +1058,7 @@ public class TestClientWithAPI {
InputStream is = method.getResponseBodyAsStream();
Map<String, String> success = getSingleValueFromXML(is, new String[] {"id"});
s_logger.info("Got dataDiskVolume with id " + success.get("id"));
- _dataVolume.set(success.get("id"));
+ s_dataVolume.set(success.get("id"));
} else {
s_logger.error("List volumes failed with error code: " + responseCode + ". Following URL was sent: " + url);
return responseCode;
@@ -1067,8 +1067,8 @@ public class TestClientWithAPI {
// Detach volume
{
- url = server + "?command=detachVolume&id=" + _dataVolume.get();
- s_logger.info("Detaching volume with id " + _dataVolume.get());
+ url = server + "?command=detachVolume&id=" + s_dataVolume.get();
+ s_logger.info("Detaching volume with id " + s_dataVolume.get());
client = new HttpClient();
method = new GetMethod(url);
responseCode = client.executeMethod(method);
@@ -1085,8 +1085,8 @@ public class TestClientWithAPI {
// Delete a volume
{
- url = server + "?command=deleteVolume&id=" + _dataVolume.get();
- s_logger.info("Deleting volume with id " + _dataVolume.get());
+ url = server + "?command=deleteVolume&id=" + s_dataVolume.get();
+ s_logger.info("Deleting volume with id " + s_dataVolume.get());
client = new HttpClient();
method = new GetMethod(url);
responseCode = client.executeMethod(method);
@@ -1101,7 +1101,7 @@ public class TestClientWithAPI {
// Create a new volume
{
- url = server + "?command=createVolume&diskofferingid=" + diskOfferingId + "&zoneid=" + zoneId + "&name=newvolume&account=" + _account.get() + "&domainid=1";
+ url = server + "?command=createVolume&diskofferingid=" + diskOfferingId + "&zoneid=" + zoneId + "&name=newvolume&account=" + s_account.get() + "&domainid=1";
s_logger.info("Creating volume....");
client = new HttpClient();
method = new GetMethod(url);
@@ -1118,7 +1118,7 @@ public class TestClientWithAPI {
s_logger.info("create volume response code: " + responseCode);
long volumeId = Long.parseLong(values.get("id"));
s_logger.info("got volume id: " + volumeId);
- _newVolume.set(values.get("id"));
+ s_newVolume.set(values.get("id"));
}
} else {
s_logger.error("create volume failed with error code: " + responseCode + ". Following URL was sent: " + url);
@@ -1128,8 +1128,8 @@ public class TestClientWithAPI {
// attach a new volume to the vm
{
- url = server + "?command=attachVolume&id=" + _newVolume.get() + "&virtualmachineid=" + _linuxVmId.get();
- s_logger.info("Attaching volume with id " + _newVolume.get() + " to the vm " + _linuxVmId.get());
+ url = server + "?command=attachVolume&id=" + s_newVolume.get() + "&virtualmachineid=" + s_linuxVmId.get();
+ s_logger.info("Attaching volume with id " + s_newVolume.get() + " to the vm " + s_linuxVmId.get());
client = new HttpClient();
method = new GetMethod(url);
responseCode = client.executeMethod(method);
@@ -1147,7 +1147,7 @@ public class TestClientWithAPI {
// Create a snapshot
// list volumes
{
- url = server + "?command=listVolumes&virtualMachineId=" + _linuxVmId.get() + "&type=root";
+ url = server + "?command=listVolumes&virtualMachineId=" + s_linuxVmId.get() + "&type=root";
s_logger.info("Getting rootDisk id of Centos vm");
client = new HttpClient();
method = new GetMethod(url);
@@ -1160,7 +1160,7 @@ public class TestClientWithAPI {
s_logger.error("Unable to get root volume. Followin url was sent: " + url);
}
s_logger.info("Got rootVolume with id " + success.get("id"));
- _rootVolume.set(success.get("id"));
+ s_rootVolume.set(success.get("id"));
} else {
s_logger.error("List volumes failed with error code: " + responseCode + ". Following URL was sent: " + url);
return responseCode;
@@ -1168,13 +1168,13 @@ public class TestClientWithAPI {
}
// //Create snapshot from root disk volume
- String encodedApiKey = URLEncoder.encode(_apiKey.get(), "UTF-8");
- String requestToSign = "apikey=" + encodedApiKey + "&command=createSnapshot&volumeid=" + _rootVolume.get();
+ String encodedApiKey = URLEncoder.encode(s_apiKey.get(), "UTF-8");
+ String requestToSign = "apikey=" + encodedApiKey + "&command=createSnapshot&volumeid=" + s_rootVolume.get();
requestToSign = requestToSign.toLowerCase();
- String signature = signRequest(requestToSign, _secretKey.get());
+ String signature = signRequest(requestToSign, s_secretKey.get());
String encodedSignature = URLEncoder.encode(signature, "UTF-8");
- url = developerServer + "?command=createSnapshot&volumeid=" + _rootVolume.get() + "&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
+ url = developerServer + "?command=createSnapshot&volumeid=" + s_rootVolume.get() + "&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
client = new HttpClient();
method = new GetMethod(url);
responseCode = client.executeMethod(method);
@@ -1189,7 +1189,7 @@ public class TestClientWithAPI {
return 401;
} else {
s_logger.info("create snapshot response code: " + responseCode + ". Got snapshot with id " + values.get("id"));
- _snapshot.set(values.get("id"));
+ s_snapshot.set(values.get("id"));
}
} else {
s_logger.error("create snapshot failed with error code: " + responseCode + ". Following URL was sent: " + url);
@@ -1197,13 +1197,13 @@ public class TestClientWithAPI {
}
// Create volume from the snapshot created on the previous step and attach it to the running vm
- /* encodedApiKey = URLEncoder.encode(_apiKey.get(), "UTF-8");
- requestToSign = "apikey=" + encodedApiKey + "&command=createVolume&name=" + _account.get() + "&snapshotid=" + _snapshot.get();
+ /* encodedApiKey = URLEncoder.encode(s_apiKey.get(), "UTF-8");
+ requestToSign = "apikey=" + encodedApiKey + "&command=createVolume&name=" + s_account.get() + "&snapshotid=" + s_snapshot.get();
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
- url = developerServer + "?command=createVolume&name=" + _account.get() + "&snapshotid=" + _snapshot.get() + "&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
+ url = developerServer + "?command=createVolume&name=" + s_account.get() + "&snapshotid=" + s_snapshot.get() + "&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
client = new HttpClient();
method = new GetMethod(url);
responseCode = client.executeMethod(method);
@@ -1218,7 +1218,7 @@ public class TestClientWithAPI {
return 401;
} else {
s_logger.info("create volume from snapshot response code: " + responseCode + ". Got volume with id " + values.get("id") + ". The command was sent with url " + url);
- _volumeFromSnapshot.set(values.get("id"));
+ s_volumeFromSnapshot.set(values.get("id"));
}
} else {
s_logger.error("create volume from snapshot failed with error code: " + responseCode + ". Following URL was sent: " + url);
@@ -1226,8 +1226,8 @@ public class TestClientWithAPI {
}
{
- url = server + "?command=attachVolume&id=" + _volumeFromSnapshot.get() + "&virtualmachineid=" + _linuxVmId.get();
- s_logger.info("Attaching volume with id " + _volumeFromSnapshot.get() + " to the vm " + _linuxVmId.get());
+ url = server + "?command=attachVolume&id=" + s_volumeFromSnapshot.get() + "&virtualmachineid=" + s_linuxVmId.get();
+ s_logger.info("Attaching volume with id " + s_volumeFromSnapshot.get() + " to the vm " + s_linuxVmId.get());
client = new HttpClient();
method = new GetMethod(url);
responseCode = client.executeMethod(method);
@@ -1247,12 +1247,12 @@ public class TestClientWithAPI {
// -----------------------------
// Reboot windows VM
- requestToSign = "apikey=" + encodedApiKey + "&command=rebootVirtualMachine&id=" + _windowsVmId.get();
+ requestToSign = "apikey=" + encodedApiKey + "&command=rebootVirtualMachine&id=" + s_windowsVmId.get();
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
- url = developerServer + "?command=rebootVirtualMachine&id=" + _windowsVmId.get() + "&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
+ url = developerServer + "?command=rebootVirtualMachine&id=" + s_windowsVmId.get() + "&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
client = new HttpClient();
method = new GetMethod(url);
responseCode = client.executeMethod(method);
@@ -1268,12 +1268,12 @@ public class TestClientWithAPI {
}
// Stop centos VM
- requestToSign = "apikey=" + encodedApiKey + "&command=stopVirtualMachine&id=" + _linuxVmId.get();
+ requestToSign = "apikey=" + encodedApiKey + "&command=stopVirtualMachine&id=" + s_linuxVmId.get();
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
- url = developerServer + "?command=stopVirtualMachine&id=" + _linuxVmId.get() + "&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
+ url = developerServer + "?command=stopVirtualMachine&id=" + s_linuxVmId.get() + "&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
client = new HttpClient();
method = new GetMethod(url);
responseCode = client.executeMethod(method);
@@ -1290,15 +1290,15 @@ public class TestClientWithAPI {
// Create private template from root disk volume
requestToSign =
- "apikey=" + encodedApiKey + "&command=createTemplate" + "&displaytext=" + _account.get() + "&name=" + _account.get() + "&ostypeid=11" + "&snapshotid=" +
- _snapshot.get();
+ "apikey=" + encodedApiKey + "&command=createTemplate" + "&displaytext=" + s_account.get() + "&name=" + s_account.get() + "&ostypeid=11" + "&snapshotid=" +
+ s_snapshot.get();
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
url =
- developerServer + "?command=createTemplate" + "&displaytext=" + _account.get() + "&name=" + _account.get() + "&ostypeid=11" + "&snapshotid=" +
- _snapshot.get() + "&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
+ developerServer + "?command=createTemplate" + "&displaytext=" + s_account.get() + "&name=" + s_account.get() + "&ostypeid=11" + "&snapshotid=" +
+ s_snapshot.get() + "&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
client = new HttpClient();
method = new GetMethod(url);
responseCode = client.executeMethod(method);
@@ -1320,12 +1320,12 @@ public class TestClientWithAPI {
}
// Start centos VM
- requestToSign = "apikey=" + encodedApiKey + "&command=startVirtualMachine&id=" + _windowsVmId.get();
+ requestToSign = "apikey=" + encodedApiKey + "&command=startVirtualMachine&id=" + s_windowsVmId.get();
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
- url = developerServer + "?command=startVirtualMachine&id=" + _windowsVmId.get() + "&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
+ url = developerServer + "?command=startVirtualMachine&id=" + s_windowsVmId.get() + "&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
client = new HttpClient();
method = new GetMethod(url);
responseCode = client.executeMethod(method);
@@ -1337,7 +1337,7 @@ public class TestClientWithAPI {
// get domainRouter id
{
- url = server + "?command=listRouters&zoneid=" + zoneId + "&account=" + _account.get() + "&domainid=1";
+ url = server + "?command=listRouters&zoneid=" + zoneId + "&account=" + s_account.get() + "&domainid=1";
client = new HttpClient();
method = new GetMethod(url);
responseCode = client.executeMethod(method);
@@ -1346,7 +1346,7 @@ public class TestClientWithAPI {
InputStream is = method.getResponseBodyAsStream();
Map<String, String> success = getSingleValueFromXML(is, new String[] {"id"});
s_logger.info("Got the domR with id " + success.get("id"));
- _domainRouterId.set(success.get("id"));
+ s_domainRouterId.set(success.get("id"));
} else {
s_logger.error("List domain routers failed with error code: " + responseCode + ". Following URL was sent: " + url);
return responseCode;
@@ -1355,8 +1355,8 @@ public class TestClientWithAPI {
// reboot the domain router
{
- url = server + "?command=rebootRouter&id=" + _domainRouterId.get();
- s_logger.info("Rebooting domR with id " + _domainRouterId.get());
+ url = server + "?command=rebootRouter&id=" + s_domainRouterId.get();
+ s_logger.info("Rebooting domR with id " + s_domainRouterId.get());
client = new HttpClient();
method = new GetMethod(url);
responseCode = client.executeMethod(method);
@@ -1375,7 +1375,7 @@ public class TestClientWithAPI {
// DELETE ACCOUNT
// -----------------------------
{
- url = server + "?command=deleteAccount&id=" + _accountId.get();
+ url = server + "?command=deleteAccount&id=" + s_accountId.get();
client = new HttpClient();
method = new GetMethod(url);
responseCode = client.executeMethod(method);
@@ -1401,9 +1401,9 @@ public class TestClientWithAPI {
// -----------------------------
// GET EVENTS
// -----------------------------
- String url = server + "?command=listEvents&page=1&pagesize=100&&account=" + _account.get();
+ String url = server + "?command=listEvents&page=1&pagesize=100&&account=" + s_account.get();
- s_logger.info("Getting events for the account " + _account.get());
+ s_logger.info("Getting events for the account " + s_account.get());
HttpClient client = new HttpClient();
HttpMethod method = new GetMethod(url);
int responseCode = client.executeMethod(method);
@@ -1457,7 +1457,7 @@ public class TestClientWithAPI {
// --------------------------------
// GET USAGE RECORDS
// --------------------------------
- url = server + "?command=listUsageRecords&startdate=2009-09-01&enddate=" + endDate + "&account=" + _account.get() + "&domaindid=1";
+ url = server + "?command=listUsageRecords&startdate=2009-09-01&enddate=" + endDate + "&account=" + s_account.get() + "&domaindid=1";
s_logger.info("Getting all usage records with request: " + url);
client = new HttpClient();
method = new GetMethod(url);
@@ -1491,7 +1491,7 @@ public class TestClientWithAPI {
private static boolean getNetworkStat(String server) {
try {
- String url = server + "?command=listAccountStatistics&account=" + _account.get();
+ String url = server + "?command=listAccountStatistics&account=" + s_account.get();
HttpClient client = new HttpClient();
HttpMethod method = new GetMethod(url);
int responseCode = client.executeMethod(method);
@@ -1502,10 +1502,10 @@ public class TestClientWithAPI {
int bytesReceived = Integer.parseInt(requestKeyValues.get("receivedbytes"));
int bytesSent = Integer.parseInt(requestKeyValues.get("sentbytes"));
if ((bytesReceived > 100000000) && (bytesSent > 0)) {
- s_logger.info("Network stat is correct for account" + _account.get() + "; bytest received is " + bytesReceived + " and bytes sent is " + bytesSent);
+ s_logger.info("Network stat is correct for account" + s_account.get() + "; bytest received is " + bytesReceived + " and bytes sent is " + bytesSent);
return true;
} else {
- s_logger.error("Incorrect value for bytes received/sent for the account " + _account.get() + ". We got " + bytesReceived + " bytes received; " +
+ s_logger.error("Incorrect value for bytes received/sent for the account " + s_account.get() + ". We got " + bytesReceived + " bytes received; " +
" and " + bytesSent + " bytes sent");
return false;
}
@@ -1531,7 +1531,7 @@ public class TestClientWithAPI {
// -----------------------------
// GET USER
// -----------------------------
- String userId = _userId.get().toString();
+ String userId = s_userId.get().toString();
String encodedUserId = URLEncoder.encode(userId, "UTF-8");
String url = server + "?command=listUsers&id=" + encodedUserId;
@@ -1560,10 +1560,10 @@ public class TestClientWithAPI {
// ----------------------------------
// LIST VIRTUAL MACHINES
// ----------------------------------
- String encodedApiKey = URLEncoder.encode(_apiKey.get(), "UTF-8");
+ String encodedApiKey = URLEncoder.encode(s_apiKey.get(), "UTF-8");
String requestToSign = "apikey=" + encodedApiKey + "&command=listVirtualMachines";
requestToSign = requestToSign.toLowerCase();
- String signature = signRequest(requestToSign, _secretKey.get());
+ String signature = signRequest(requestToSign, s_secretKey.get());
String encodedSignature = URLEncoder.encode(signature, "UTF-8");
url = developerServer + "?command=listVirtualMachines&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
@@ -1604,7 +1604,7 @@ public class TestClientWithAPI {
requestToSign = "apikey=" + encodedApiKey + "&command=listPublicIpAddresses";
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
url = developerServer + "?command=listPublicIpAddresses&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
@@ -1643,7 +1643,7 @@ public class TestClientWithAPI {
requestToSign = "apikey=" + encodedApiKey + "&command=listZones";
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
url = developerServer + "?command=listZones&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
@@ -1684,7 +1684,7 @@ public class TestClientWithAPI {
requestToSign = "apikey=" + encodedApiKey + "&command=listAccounts";
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
url = developerServer + "?command=listAccounts&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
@@ -1725,7 +1725,7 @@ public class TestClientWithAPI {
requestToSign = "apikey=" + encodedApiKey + "&command=listTemplates@templatefilter=self";
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
url = developerServer + "?command=listTemplates&apikey=" + encodedApiKey + "&templatefilter=self&signature=" + encodedSignature;
@@ -1767,7 +1767,7 @@ public class TestClientWithAPI {
requestToSign = "apikey=" + encodedApiKey + "&command=listServiceOfferings";
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
url = developerServer + "?command=listServiceOfferings&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
@@ -1805,7 +1805,7 @@ public class TestClientWithAPI {
// LIST EVENTS
// ---------------------------------
- url = server + "?command=listEvents&page=1&pagesize=100&&account=" + _account.get();
+ url = server + "?command=listEvents&page=1&pagesize=100&&account=" + s_account.get();
String[] eventDescriptions = null;
client = new HttpClient();
method = new GetMethod(url);
@@ -1844,7 +1844,7 @@ public class TestClientWithAPI {
for (String vmId : vmIds) {
requestToSign = "apikey=" + encodedApiKey + "&command=" + cmdName + "&id=" + vmId;
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
url = developerServer + "?command=" + cmdName + "&id=" + vmId + "&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
@@ -1870,10 +1870,10 @@ public class TestClientWithAPI {
// -----------------------------------------
// LIST NAT IP ADDRESSES
// -----------------------------------------
- String encodedApiKey = URLEncoder.encode(_apiKey.get(), "UTF-8");
+ String encodedApiKey = URLEncoder.encode(s_apiKey.get(), "UTF-8");
String requestToSign = "apikey=" + encodedApiKey + "&command=listPublicIpAddresses";
requestToSign = requestToSign.toLowerCase();
- String signature = signRequest(requestToSign, _secretKey.get());
+ String signature = signRequest(requestToSign, s_secretKey.get());
String encodedSignature = URLEncoder.encode(signature, "UTF-8");
url = developerServer + "?command=listPublicIpAddresses&apikey=" + encodedApiKey + "&signature=" + encodedSignature;
@@ -1904,11 +1904,11 @@ public class TestClientWithAPI {
// -------------------------------------------------------------
// Delete IP FORWARDING RULE -- Windows VM
// -------------------------------------------------------------
- String encodedIpFwdId = URLEncoder.encode(_winipfwdid.get(), "UTF-8");
+ String encodedIpFwdId = URLEncoder.encode(s_winipfwdid.get(), "UTF-8");
requestToSign = "apikey=" + encodedApiKey + "&command=deleteIpForwardingRule&id=" + encodedIpFwdId;
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
url = developerServer + "?command=deleteIpForwardingRule&apikey=" + encodedApiKey + "&id=" + encodedIpFwdId + "&signature=" + encodedSignature;
@@ -1929,11 +1929,11 @@ public class TestClientWithAPI {
//--------------------------------------------
// Disable Static NAT for the Source NAT Ip
//--------------------------------------------
- encodedApiKey = URLEncoder.encode(_apiKey.get(), "UTF-8");
- String encodedPublicIpId = URLEncoder.encode(_publicIpId.get(), "UTF-8");
+ encodedApiKey = URLEncoder.encode(s_apiKey.get(), "UTF-8");
+ String encodedPublicIpId = URLEncoder.encode(s_publicIpId.get(), "UTF-8");
requestToSign = "apikey=" + encodedApiKey + "&command=disableStaticNat" + "&id=" + encodedPublicIpId;
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
url = developerServer + "?command=disableStaticNat&apikey=" + encodedApiKey + "&id=" + encodedPublicIpId + "&signature=" + encodedSignature;
@@ -1958,7 +1958,7 @@ public class TestClientWithAPI {
for (String ipAddress : ipAddresses) {
requestToSign = "apikey=" + encodedApiKey + "&command=disassociateIpAddress&id=" + ipAddress;
requestToSign = requestToSign.toLowerCase();
- signature = signRequest(requestToSign, _secretKey.get());
+ signature = signRequest(requestToSign, s_secretKey.get());
encodedSignature = URLEncoder.encode(signature, "UTF-8");
url = developerServer + "?command=disassociateIpAddress&apikey=" + encodedApiKey + "&id=" + ipAddress + "&signature=" + encodedSignature;
@@ -1979,18 +1979,18 @@ public class TestClientWithAPI {
}
}
}
- _linuxIP.set("");
- _linuxIpId.set("");
- _linuxVmId.set("");
- _linuxPassword.set("");
- _windowsIP.set("");
- _windowsIpId.set("");
- _windowsVmId.set("");
- _secretKey.set("");
- _apiKey.set("");
- _userId.set(Long.parseLong("0"));
- _account.set("");
- _domainRouterId.set("");
+ s_linuxIP.set("");
+ s_linuxIpId.set("");
+ s_linuxVmId.set("");
+ s_linuxPassword.set("");
+ s_windowsIP.set("");
+ s_windowsIpId.set("");
+ s_windowsVmId.set("");
+ s_secretKey.set("");
+ s_apiKey.set("");
+ s_userId.set(Long.parseLong("0"));
+ s_account.set("");
+ s_domainRouterId.set("");
return responseCode;
}
@@ -2020,16 +2020,16 @@ public class TestClientWithAPI {
while (true) {
try {
if (retry > 0) {
- s_logger.info("Retry attempt : " + retry + " ...sleeping 300 seconds before next attempt. Account is " + _account.get());
+ s_logger.info("Retry attempt : " + retry + " ...sleeping 300 seconds before next attempt. Account is " + s_account.get());
Thread.sleep(300000);
}
- s_logger.info("Attempting to SSH into windows host " + host + " with retry attempt: " + retry + " for account " + _account.get());
+ s_logger.info("Attempting to SSH into windows host " + host + " with retry attempt: " + retry + " for account " + s_account.get());
Connection conn = new Connection(host);
conn.connect(null, 60000, 60000);
- s_logger.info("User " + _account.get() + " ssHed successfully into windows host " + host);
+ s_logger.info("User " + s_account.get() + " ssHed successfully into windows host " + host);
boolean success = false;
boolean isAuthenticated = conn.authenticateWithPassword("Administrator", "password");
if (isAuthenticated == false) {
@@ -2051,7 +2051,7 @@ public class TestClientWithAPI {
}
Session sess = conn.openSession();
- s_logger.info("User + " + _account.get() + " executing : wget http://" + downloadUrl);
+ s_logger.info("User + " + s_account.get() + " executing : wget http://" + downloadUrl);
String downloadCommand = "wget http://" + downloadUrl + " && dir dump.bin";
sess.execCommand(downloadCommand);
@@ -2094,7 +2094,7 @@ public class TestClientWithAPI {
} else {
retry++;
if (retry == MAX_RETRY_WIN) {
- return "SSH Windows Network test fail for account " + _account.get();
+ return "SSH Windows Network test fail for account " + s_account.get();
}
}
} catch (Exception e) {
@@ -2107,7 +2107,7 @@ public class TestClientWithAPI {
}
}
- private static String sshTest(String host, String password, String snapshot_test) {
+ private static String sshTest(String host, String password, String snapshotTest) {
int i = 0;
if (host == null) {
s_logger.info("Did not receive a host back from test, ignoring ssh test");
@@ -2126,16 +2126,16 @@ public class TestClientWithAPI {
while (true) {
try {
if (retry > 0) {
- s_logger.info("Retry attempt : " + retry + " ...sleeping 120 seconds before next attempt. Account is " + _account.get());
+ s_logger.info("Retry attempt : " + retry + " ...sleeping 120 seconds before next attempt. Account is " + s_account.get());
Thread.sleep(120000);
}
- s_logger.info("Attempting to SSH into linux host " + host + " with retry attempt: " + retry + ". Account is " + _account.get());
+ s_logger.info("Attempting to SSH into linux host " + host + " with retry attempt: " + retry + ". Account is " + s_account.get());
Connection conn = new Connection(host);
conn.connect(null, 60000, 60000);
- s_logger.info("User + " + _account.get() + " ssHed successfully into linux host " + host);
+ s_logger.info("User + " + s_account.get() + " ssHed successfully into linux host " + host);
boolean isAuthenticated = conn.authenticateWithPassword("root", password);
@@ -2154,7 +2154,7 @@ public class TestClientWithAPI {
linuxCommand = "wget http://" + downloadUrl + " && ls -al dump.bin";
Session sess = conn.openSession();
- s_logger.info("User " + _account.get() + " executing : " + linuxCommand);
+ s_logger.info("User " + s_account.get() + " executing : " + linuxCommand);
sess.execCommand(linuxCommand);
InputStream stdout = sess.getStdout();
@@ -2199,7 +2199,7 @@ public class TestClientWithAPI {
}
}
- if (snapshot_test.equals("no"))
+ if (snapshotTest.equals("no"))
return result;
else {
Long sleep = 300000L;
@@ -2209,7 +2209,7 @@ public class TestClientWithAPI {
} catch (Exception e) {
retry++;
s_logger.error("SSH Linux Network test fail with error");
- if ((retry == MAX_RETRY_LINUX) && (snapshot_test.equals("no"))) {
+ if ((retry == MAX_RETRY_LINUX) && (snapshotTest.equals("no"))) {
return "SSH Linux Network test fail with error " + e.getMessage();
}
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/test/src/com/cloud/test/stress/WgetTest.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/stress/WgetTest.java b/test/src/com/cloud/test/stress/WgetTest.java
index a972081..9188556 100644
--- a/test/src/com/cloud/test/stress/WgetTest.java
+++ b/test/src/com/cloud/test/stress/WgetTest.java
@@ -29,7 +29,7 @@ import com.trilead.ssh2.Session;
public class WgetTest {
- public static int MAX_RETRY_LINUX = 1;
+ public static final int MAX_RETRY_LINUX = 1;
public static final Logger s_logger = Logger.getLogger(WgetTest.class.getName());
public static String host = "";
public static String password = "rs-ccb35ea5";
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/test/src/com/cloud/test/utils/ConsoleProxy.java
----------------------------------------------------------------------
diff --git a/test/src/com/cloud/test/utils/ConsoleProxy.java b/test/src/com/cloud/test/utils/ConsoleProxy.java
index 2329247..bc77bc9 100644
--- a/test/src/com/cloud/test/utils/ConsoleProxy.java
+++ b/test/src/com/cloud/test/utils/ConsoleProxy.java
@@ -54,7 +54,7 @@ public class ConsoleProxy implements Runnable {
myScript.add(command);
myScript.execute();
long begin = System.currentTimeMillis();
- wgetInt process = new wgetInt();
+ WgetInt process = new WgetInt();
String response = myScript.execute(process);
long end = process.getEnd();
if (response != null) {
@@ -73,7 +73,7 @@ public class ConsoleProxy implements Runnable {
}
}
- public class wgetInt extends OutputInterpreter {
+ public class WgetInt extends OutputInterpreter {
private long end;
public long getEnd() {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/usage/src/com/cloud/usage/UsageAlertManagerImpl.java
----------------------------------------------------------------------
diff --git a/usage/src/com/cloud/usage/UsageAlertManagerImpl.java b/usage/src/com/cloud/usage/UsageAlertManagerImpl.java
index 0f86e85..67bb702 100644
--- a/usage/src/com/cloud/usage/UsageAlertManagerImpl.java
+++ b/usage/src/com/cloud/usage/UsageAlertManagerImpl.java
@@ -175,7 +175,8 @@ public class UsageAlertManagerImpl extends ManagerBase implements AlertManager {
}
// TODO: make sure this handles SSL transport (useAuth is true) and regular
- protected void sendAlert(AlertType alertType, long dataCenterId, Long podId, String subject, String content) throws MessagingException, UnsupportedEncodingException {
+ protected void sendAlert(AlertType alertType, long dataCenterId, Long podId, String subject, String content) throws MessagingException,
+ UnsupportedEncodingException {
s_alertsLogger.warn(" alertType:: " + alertType + " // dataCenterId:: " + dataCenterId + " // podId:: " +
podId + " // clusterId:: " + null + " // message:: " + subject);
AlertVO alert = null;
@@ -249,7 +250,6 @@ public class UsageAlertManagerImpl extends ManagerBase implements AlertManager {
}
-
@Override
public boolean generateAlert(AlertType alertType, long dataCenterId, Long podId, String msg) {
try {
@@ -258,6 +258,6 @@ public class UsageAlertManagerImpl extends ManagerBase implements AlertManager {
} catch (Exception ex) {
s_logger.warn("Failed to generate an alert of type=" + alertType + "; msg=" + msg);
return false;
- }
+ }
}
}