diff options
Diffstat (limited to 'appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org')
2 files changed, 19 insertions, 17 deletions
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/ApiMethod.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/ApiMethod.java index 19e381ec5..de4f31a04 100644 --- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/ApiMethod.java +++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/ApiMethod.java @@ -24,25 +24,19 @@ package org.openecomp.appc.adapter.chef.chefapi; -import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; -import org.apache.http.*; -import org.apache.http.client.*; -import org.apache.http.client.methods.*; -import org.apache.http.impl.client.*; +import org.apache.http.HttpResponse; +import org.apache.http.Header; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.util.EntityUtils; import org.openecomp.appc.adapter.chef.chefclient.Utils; -import javax.net.ssl.SSLContext; -import java.io.File; import org.apache.http.HttpEntity; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.conn.ssl.TrustSelfSignedStrategy; import org.apache.http.impl.client.HttpClients; -import org.apache.http.ssl.SSLContexts; public class ApiMethod { private HttpClient client = null; @@ -64,7 +58,7 @@ public class ApiMethod { this.methodName = methodName; } - public ApiMethod execute() { + public ApiMethod createRequest(){ String hashedPath = Utils.sha1AndBase64("/organizations/"+organizations+chefPath); String hashedBody = Utils.sha1AndBase64(reqBody); @@ -101,11 +95,15 @@ public class ApiMethod { * RHS=this.method.getHeaders(); for (int i = 0; i < RHS.length; i++) { * test=test+RHS[i]+"\n"; } test=test+this.reqBody+"\n"; */ + return this; + } + + public ApiMethod execute() { try{ - response = client.execute(method); - resCode = response.getStatusLine().getStatusCode(); - HttpEntity entity1 = response.getEntity(); - responseBody = EntityUtils.toString(entity1);} + response = client.execute(method); + resCode = response.getStatusLine().getStatusCode(); + HttpEntity entity1 = response.getEntity(); + responseBody = EntityUtils.toString(entity1);} catch(Exception ex){ resCode=500; responseBody=ex.getMessage(); diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/ChefAdapterImpl.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/ChefAdapterImpl.java index b81c10bc8..ab853dcc4 100644 --- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/ChefAdapterImpl.java +++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/ChefAdapterImpl.java @@ -145,7 +145,11 @@ public class ChefAdapterImpl implements ChefAdapter { serverAddress = params.get("org.openecomp.appc.instance.serverAddress"); organizations = params.get("org.openecomp.appc.instance.organizations"); chefserver = "https://" + serverAddress + ORGANIZATIONS_STR + organizations; - clientPrivatekey = "/opt/app/bvc/chef/" + serverAddress + "/" + organizations + "/" + clientName + ".pem"; + if (params.containsKey("org.openecomp.appc.instance.pemPath")) { + clientPrivatekey = params.get("org.openecomp.appc.instance.pemPath"); + } else { + clientPrivatekey = "/opt/app/bvc/chef/" + serverAddress + "/" + organizations + "/" + clientName + ".pem"; + } } public Boolean privateKeyCheck() { @@ -444,7 +448,7 @@ public class ChefAdapterImpl implements ChefAdapter { configuration = ConfigurationFactory.getConfiguration(); // need to fetch data from appc configurator or form some file in the appc vms clientName = "testnode"; - clientPrivatekey = "/etc/chef/client.pem"; + clientPrivatekey = System.getProperty("user.dir") + "/src/test/resources/testclient.pem"; serverAddress = "http://example.com"; organizations = "test"; chefserver = serverAddress + ORGANIZATIONS_STR + organizations; |