Merge of new rebased code
[appc.git] / appc-adapters / appc-chef-adapter / appc-chef-adapter-bundle / src / main / java / org / openecomp / appc / adapter / chef / impl / ChefAdapterImpl.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : APP-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                                              reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.openecomp.appc.adapter.chef.impl;
23
24 import java.net.URI;
25 import java.util.ArrayList;
26 import java.util.HashMap;
27 import java.util.List;
28 import java.util.Map;
29 import java.util.Properties;
30 import java.util.Set;
31 import java.util.regex.Pattern;
32
33 import org.glassfish.grizzly.http.util.HttpStatus;
34 import org.openecomp.appc.Constants;
35 import org.openecomp.appc.adapter.chef.ChefAdapter;
36 import org.openecomp.appc.adapter.chef.chefapi.*;
37 import org.openecomp.appc.adapter.chef.chefclient.*;
38 import org.openecomp.appc.configuration.Configuration;
39 import org.openecomp.appc.configuration.ConfigurationFactory;
40 import org.openecomp.appc.exceptions.APPCException;
41 import org.openecomp.appc.exceptions.UnknownProviderException;
42 import org.openecomp.appc.i18n.Msg;
43 import org.openecomp.appc.pool.Pool;
44 import org.openecomp.appc.pool.PoolExtensionException;
45 import org.openecomp.appc.util.StructuredPropertyHelper;
46 import org.openecomp.appc.util.StructuredPropertyHelper.Node;
47 import com.att.cdp.exceptions.ContextConnectionException;
48 import com.att.cdp.exceptions.ResourceNotFoundException;
49 import com.att.cdp.exceptions.TimeoutException;
50 import com.att.cdp.exceptions.ZoneException;
51 import com.att.cdp.pal.util.StringHelper;
52 import com.att.cdp.zones.ComputeService;
53 import com.att.cdp.zones.Context;
54 import com.att.cdp.zones.ImageService;
55 import com.att.cdp.zones.Provider;
56 import com.att.cdp.zones.model.Image;
57 import com.att.cdp.zones.model.Server;
58 import com.att.cdp.zones.model.ServerBootSource;
59 import com.att.cdp.zones.model.Server.Status;
60 import com.att.eelf.configuration.EELFLogger;
61 import com.att.eelf.configuration.EELFManager;
62 import com.att.eelf.i18n.EELFResourceManager;
63 import org.openecomp.sdnc.sli.SvcLogicContext;
64 import org.slf4j.MDC;
65
66 import java.net.InetAddress;
67 import java.util.Locale;
68 import java.util.UUID;
69
70 import org.apache.http.*;
71 import org.apache.http.client.*;
72 import org.apache.http.client.methods.*;
73 import org.apache.http.impl.client.*;
74 import org.apache.http.util.EntityUtils;
75
76 import static com.att.eelf.configuration.Configuration.*;
77
78 import java.io.IOException;
79
80 import java.net.InetAddress;
81
82 import java.io.BufferedInputStream;
83 import java.io.File;
84 import java.io.FileInputStream;
85 import java.io.FileOutputStream;
86 import java.io.IOException;
87 import java.io.InputStream;
88 import java.io.OutputStream;
89 import java.util.Properties;
90 //chef
91 import org.openecomp.appc.adapter.chef.chefapi.*;
92 import org.openecomp.appc.adapter.chef.chefclient.*;
93
94 //json
95 import org.json.JSONArray;
96 import org.json.JSONException;
97 import org.json.JSONObject;
98 /**
99  * This class implements the {@link ChefAdapter} interface. This interface
100  * defines the behaviors that our service provides.
101  */
102 public class ChefAdapterImpl implements ChefAdapter {
103
104         /**
105          * The constant used to define the adapter name in the mapped diagnostic
106          * context
107          */
108         
109         //chef server Initialize variable
110         public String clientName="";
111         public String clientPrivatekey="";
112         public String chefserver="";
113         public String serverAddress="";
114         public String organizations="";
115         @SuppressWarnings("nls")
116         public static final String MDC_ADAPTER = "adapter";
117
118         /**
119          * The constant used to define the service name in the mapped diagnostic
120          * context
121          */
122         @SuppressWarnings("nls")
123         public static final String MDC_SERVICE = "service";
124
125         /**
126          * The constant for the status code for a failed outcome
127          */
128         @SuppressWarnings("nls")
129         public static final String OUTCOME_FAILURE = "failure";
130
131         /**
132          * The constant for the status code for a successful outcome
133          */
134         @SuppressWarnings("nls")
135         public static final String OUTCOME_SUCCESS = "success";
136
137         /**
138          * A constant for the property token "provider" used in the structured
139          * property specifications
140          */
141         @SuppressWarnings("nls")
142         public static final String PROPERTY_PROVIDER = "provider";
143
144         /**
145          * A constant for the property token "identity" used in the structured
146          * property specifications
147          */
148         @SuppressWarnings("nls")
149         public static final String PROPERTY_PROVIDER_IDENTITY = "identity";
150
151         /**
152          * A constant for the property token "name" used in the structured property
153          * specifications
154          */
155         @SuppressWarnings("nls")
156         public static final String PROPERTY_PROVIDER_NAME = "name";
157
158         /**
159          * A constant for the property token "tenant" used in the structured
160          * property specifications
161          */
162         @SuppressWarnings("nls")
163         public static final String PROPERTY_PROVIDER_TENANT = "tenant";
164
165         /**
166          * A constant for the property token "tenant name" used in the structured
167          * property specifications
168          */
169         @SuppressWarnings("nls")
170         public static final String PROPERTY_PROVIDER_TENANT_NAME = "name";
171
172         /**
173          * A constant for the property token "password" used in the structured
174          * property specifications
175          */
176         @SuppressWarnings("nls")
177         public static final String PROPERTY_PROVIDER_TENANT_PASSWORD = "password"; // NOSONAR
178
179         /**
180          * A constant for the property token "userid" used in the structured
181          * property specifications
182          */
183         @SuppressWarnings("nls")
184         public static final String PROPERTY_PROVIDER_TENANT_USERID = "userid";
185
186         /**
187          * A constant for the property token "type" used in the structured property
188          * specifications
189          */
190         @SuppressWarnings("nls")
191         public static final String PROPERTY_PROVIDER_TYPE = "type";
192
193         /**
194          * The name of the service to restart a server
195          */
196         @SuppressWarnings("nls")
197         public static final String PING_SERVICE = "pingServer";
198
199         /**
200          * The logger to be used
201          */
202         private static final EELFLogger logger = EELFManager.getInstance().getLogger(ChefAdapterImpl.class);
203
204         /**
205          * The constant for a left parenthesis
206          */
207         private static final char LPAREN = '(';
208
209         /**
210          * The constant for a new line control code
211          */
212         private static final char NL = '\n';
213
214         /**
215          * The constant for a single quote
216          */
217         private static final char QUOTE = '\'';
218
219         /**
220          * The constant for a right parenthesis
221          */
222         private static final char RPAREN = ')';
223
224         /**
225          * The constant for a space
226          */
227         private static final char SPACE = ' ';
228
229         /**
230          * A reference to the adapter configuration object.
231          */
232         private Configuration configuration;
233
234         /**
235          * This default constructor is used as a work around because the activator
236          * wasnt getting called
237          */
238         public ChefAdapterImpl() {
239                 initialize();
240
241         }
242
243         /**
244          * This constructor is used primarily in the test cases to bypass
245          * initialization of the adapter for isolated, disconnected testing
246          * 
247          * @param initialize
248          *            True if the adapter is to be initialized, can false if not
249          */
250         public ChefAdapterImpl(boolean initialize) {
251                 configuration = ConfigurationFactory.getConfiguration();
252                 if (initialize) {
253                         initialize();
254
255                 }
256         }
257
258         /**
259          * @param props
260          *            not used
261          */
262         public ChefAdapterImpl(Properties props) {
263                 initialize();
264
265         }
266
267         public ChefAdapterImpl(String key) {
268                 initialize(key);
269
270         }
271         
272         /**
273          * Returns the symbolic name of the adapter
274          * 
275          * @return The adapter name
276          * @see org.openecomp.appc.adapter.chef.ChefAdapter#getAdapterName()
277          */
278         @Override
279         public String getAdapterName() {
280                 return configuration.getProperty(Constants.PROPERTY_ADAPTER_NAME);
281         }
282
283         private void X__________________________________X() {
284         }
285
286         /**
287          * @see org.openecomp.appc.adapter.chef.ChefAdapter#evacuateServer(java.util.Map,
288          *      org.openecomp.sdnc.sli.SvcLogicContext)
289          */
290
291         private void X___________________________________X() {
292         }
293
294         /**
295          * @see org.openecomp.appc.adapter.chef.ProviderAdapter#rebuildServer(java.util.Map,
296          *      org.openecomp.sdnc.sli.SvcLogicContext)
297          */
298
299         
300         /**
301          * build node object
302          */
303
304         @SuppressWarnings("nls")
305         @Override
306         public void nodeObejctBuilder(Map<String, String> params, SvcLogicContext ctx) {
307                 logger.info("nodeObejctBuilder");
308                 String name = params.get("org.openecomp.appc.instance.nodeobject.name");
309                 String normal = params.get("org.openecomp.appc.instance.nodeobject.normal");
310                 String overrides = params.get("org.openecomp.appc.instance.nodeobject.overrides");
311                 String defaults = params.get("org.openecomp.appc.instance.nodeobject.defaults");
312                 String run_list = params.get("org.openecomp.appc.instance.nodeobject.run_list");
313                 String chef_environment = params.get("org.openecomp.appc.instance.nodeobject.chef_environment");
314                 String nodeObject = "{\"json_class\":\"Chef::Node\",\"default\":{" + defaults
315                                 + "},\"chef_type\":\"node\",\"run_list\":[" + run_list + "],\"override\":{" + overrides
316                                 + "},\"normal\": {" + normal + "},\"automatic\":{},\"name\":\"" + name + "\",\"chef_environment\":\""
317                                 + chef_environment + "\"}";
318                 logger.info(nodeObject);
319
320                 RequestContext rc = new RequestContext(ctx);
321                 rc.isAlive();
322                 SvcLogicContext svcLogic = rc.getSvcLogicContext();
323                 svcLogic.setAttribute("org.openecomp.appc.chef.nodeObject", nodeObject);
324
325         }
326
327         /**
328          * Send get request to chef server
329          */
330
331         public void chefInfo(Map<String, String> params) {
332                 clientName = params.get("org.openecomp.appc.instance.username");
333                 serverAddress = params.get("org.openecomp.appc.instance.serverAddress");
334                 organizations = params.get("org.openecomp.appc.instance.organizations");
335                 chefserver = "https://" + serverAddress + "/organizations/" + organizations;
336                 clientPrivatekey = "/opt/openecomp/appc/chef/" + serverAddress + "/" + organizations + "/" + clientName + ".pem";
337         }
338
339         public Boolean privateKeyCheck() {
340                 File f = new File(clientPrivatekey);
341                 if (f.exists()) {
342                         return true;
343                 } else {
344                         return false;
345                 }
346         }
347
348         @SuppressWarnings("nls")
349         @Override
350         public void retrieveData(Map<String, String> params, SvcLogicContext ctx) {
351                 String contextData = "someValue";
352                 String allConfigData = params.get("org.openecomp.appc.instance.allConfig");
353                 String key = params.get("org.openecomp.appc.instance.key");
354                 String dgContext = params.get("org.openecomp.appc.instance.dgContext");
355                 JSONObject josnConfig = new JSONObject(allConfigData);
356                 try {
357                         contextData = josnConfig.getString(key);
358                 } catch (Exception ex) {
359                         try {
360                                 contextData = josnConfig.getJSONObject(key).toString();
361                         } catch (Exception exc) {
362                                 contextData = josnConfig.getJSONArray(key).toString();
363                         }
364                 }
365
366                 RequestContext rc = new RequestContext(ctx);
367                 rc.isAlive();
368                 SvcLogicContext svcLogic = rc.getSvcLogicContext();
369                 svcLogic.setAttribute(dgContext, contextData);
370         }
371
372         @SuppressWarnings("nls")
373         @Override
374         public void combineStrings(Map<String, String> params, SvcLogicContext ctx) {
375
376                 String String1 = params.get("org.openecomp.appc.instance.String1");
377                 String String2 = params.get("org.openecomp.appc.instance.String2");
378                 String dgContext = params.get("org.openecomp.appc.instance.dgContext");
379                 String contextData = String1 + String2;
380                 RequestContext rc = new RequestContext(ctx);
381                 rc.isAlive();
382                 SvcLogicContext svcLogic = rc.getSvcLogicContext();
383                 svcLogic.setAttribute(dgContext, contextData);
384         }
385         
386         
387         /**
388          * Send GET request to chef server
389          */
390
391         @SuppressWarnings("nls")
392         @Override
393         public void chefGet(Map<String, String> params, SvcLogicContext ctx) {
394                 logger.info("chef get method");
395                 chefInfo(params);
396                 String chefAction = params.get("org.openecomp.appc.instance.chefAction");
397                 RequestContext rc = new RequestContext(ctx);
398                 rc.isAlive();
399                 int code;
400                 String message = null;
401                 if (privateKeyCheck()) {
402                         ChefApiClient cac = new ChefApiClient(clientName, clientPrivatekey, chefserver, organizations);
403                         ApiMethod am = cac.get(chefAction);
404                         am.execute();
405                         code = am.getReturnCode();
406                         message = am.getResponseBodyAsString();
407                 } else {
408                         code = 500;
409                         message = "Cannot find the private key in the APPC file system, please load the private key to "
410                                         + clientPrivatekey;
411                 }
412                 chefServerResult(rc, Integer.toString(code), message);
413
414         }
415
416         /**
417          * Send PUT request to chef server
418          */
419
420         @SuppressWarnings("nls")
421         @Override
422         public void chefPut(Map<String, String> params, SvcLogicContext ctx) {
423                 chefInfo(params);
424                 String chefAction = params.get("org.openecomp.appc.instance.chefAction");
425                 String CHEF_NODE_STR = params.get("org.openecomp.appc.instance.chefRequestBody");
426                 RequestContext rc = new RequestContext(ctx);
427                 rc.isAlive();
428                 int code;
429                 String message = null;
430                 if (privateKeyCheck()) {
431                         ChefApiClient cac = new ChefApiClient(clientName, clientPrivatekey, chefserver, organizations);
432
433                         ApiMethod am = cac.put(chefAction).body(CHEF_NODE_STR);
434                         am.execute();
435                         code = am.getReturnCode();
436                         message = am.getResponseBodyAsString();
437                 } else {
438                         code = 500;
439                         message = "Cannot find the private key in the APPC file system, please load the private key to "
440                                         + clientPrivatekey;
441                 }
442                 logger.info(code + "   " + message);
443                 chefServerResult(rc, Integer.toString(code), message);
444
445         }
446         
447         /**
448          * Send Post request to chef server
449          */
450
451         @SuppressWarnings("nls")
452         @Override
453         public void chefPost(Map<String, String> params, SvcLogicContext ctx) {
454                 chefInfo(params);
455                 logger.info("chef Post method");
456                 logger.info(clientName + " " + clientPrivatekey + " " + chefserver + " " + organizations);
457                 String CHEF_NODE_STR = params.get("org.openecomp.appc.instance.chefRequestBody");
458                 String chefAction = params.get("org.openecomp.appc.instance.chefAction");
459                 RequestContext rc = new RequestContext(ctx);
460                 rc.isAlive();
461                 int code;
462                 String message = null;
463                 // should load pem from somewhere else
464                 if (privateKeyCheck()) {
465                         ChefApiClient cac = new ChefApiClient(clientName, clientPrivatekey, chefserver, organizations);
466
467                         // need pass path into it
468                         // "/nodes/testnode"
469                         ApiMethod am = cac.post(chefAction).body(CHEF_NODE_STR);
470                         am.execute();
471                         code = am.getReturnCode();
472                         message = am.getResponseBodyAsString();
473                 } else {
474                         code = 500;
475                         message = "Cannot find the private key in the APPC file system, please load the private key to "
476                                         + clientPrivatekey;
477                 }
478                 logger.info(code + "   " + message);
479                 chefServerResult(rc, Integer.toString(code), message);
480         }
481
482         /**
483          * Send delete request to chef server
484          */
485
486         @SuppressWarnings("nls")
487         @Override
488         public void chefDelete(Map<String, String> params, SvcLogicContext ctx) {
489                 logger.info("chef delete method");
490                 chefInfo(params);
491                 String chefAction = params.get("org.openecomp.appc.instance.chefAction");
492                 RequestContext rc = new RequestContext(ctx);
493                 rc.isAlive();
494                 int code;
495                 String message = null;
496                 if (privateKeyCheck()) {
497                         ChefApiClient cac = new ChefApiClient(clientName, clientPrivatekey, chefserver, organizations);
498                         ApiMethod am = cac.delete(chefAction);
499                         am.execute();
500                         code = am.getReturnCode();
501                         message = am.getResponseBodyAsString();
502                 } else {
503                         code = 500;
504                         message = "Cannot find the private key in the APPC file system, please load the private key to "
505                                         + clientPrivatekey;
506                 }
507                 logger.info(code + "   " + message);
508                 chefServerResult(rc, Integer.toString(code), message);
509         }
510         
511         
512         /**
513          * Trigger target vm run chef
514          */
515
516         @SuppressWarnings("nls")
517         @Override
518         public void trigger(Map<String, String> params, SvcLogicContext ctx) {
519                 logger.info("Run trigger method");
520                 String tVmIp = params.get("org.openecomp.appc.instance.ip");
521                 RequestContext rc = new RequestContext(ctx);
522                 rc.isAlive();
523
524                 try {
525                         HttpGet httpGet = new HttpGet(tVmIp);
526                         HttpClient httpClient = HttpClients.createDefault();
527                         HttpResponse response = null;
528                         response = httpClient.execute(httpGet);
529                         int responseCode=response.getStatusLine().getStatusCode();
530                         HttpEntity entity = response.getEntity();
531                         String responseOutput=EntityUtils.toString(entity);
532                         chefClientResult(rc,Integer.toString(responseCode),responseOutput);
533                         doSuccess(rc);
534                 } catch (Exception ex) {
535                         doFailure(rc, 500 , ex.toString());
536                 }
537         }
538         
539
540         @SuppressWarnings("nls")
541         @Override
542         public void checkPushJob(Map<String, String> params, SvcLogicContext ctx) {
543                 chefInfo(params);
544                 String jobID = params.get("org.openecomp.appc.instance.jobid");
545                 int retryTimes = Integer.parseInt(params.get("org.openecomp.appc.instance.retryTimes"));
546                 int retryInterval = Integer.parseInt(params.get("org.openecomp.appc.instance.retryInterval"));
547                 String chefAction = "/pushy/jobs/" + jobID;
548
549                 RequestContext rc = new RequestContext(ctx);
550                 rc.isAlive();
551                 SvcLogicContext svcLogic = rc.getSvcLogicContext();
552                 String message = "";
553                 String status = "";
554                 for (int i = 0; i < retryTimes; i++) {
555                         try {
556                                 Thread.sleep(retryInterval); // 1000 milliseconds is one second.
557                         } catch (InterruptedException ex) {
558                                 Thread.currentThread().interrupt();
559                         }
560                         ChefApiClient cac = new ChefApiClient(clientName, clientPrivatekey, chefserver, organizations);
561                         ApiMethod am = cac.get(chefAction);
562                         am.execute();
563                         int code = am.getReturnCode();
564                         message = am.getResponseBodyAsString();
565                         JSONObject obj = new JSONObject(message);
566                         status = obj.getString("status");
567                         if (!status.equals("running")) {
568                                 logger.info(i + " time " + code + "   " + status);
569                                 break;
570                         }
571
572                 }
573                 if (status.equals("complete")) {
574                         svcLogic.setAttribute("org.openecomp.appc.chefServerResult.code", "200");
575                         svcLogic.setAttribute("org.openecomp.appc.chefServerResult.message", message);
576                 } else {
577                         if (status.equals("running")) {
578                                 svcLogic.setAttribute("org.openecomp.appc.chefServerResult.code", "202");
579                                 svcLogic.setAttribute("org.openecomp.appc.chefServerResult.message", "chef client runtime out");
580                         } else {
581                                 svcLogic.setAttribute("org.openecomp.appc.chefServerResult.code", "500");
582                                 svcLogic.setAttribute("org.openecomp.appc.chefServerResult.message", message);
583                         }
584                 }
585         }
586
587
588         @SuppressWarnings("nls")
589         @Override
590         public void pushJob(Map<String, String> params, SvcLogicContext ctx) {
591                 chefInfo(params);
592                 String pushRequest = params.get("org.openecomp.appc.instance.pushRequest");
593                 String chefAction = "/pushy/jobs";
594                 RequestContext rc = new RequestContext(ctx);
595                 rc.isAlive();
596                 SvcLogicContext svcLogic = rc.getSvcLogicContext();
597                 ChefApiClient cac = new ChefApiClient(clientName, clientPrivatekey, chefserver, organizations);
598                 ApiMethod am = cac.post(chefAction).body(pushRequest);
599                 ;
600                 am.execute();
601                 int code = am.getReturnCode();
602                 String message = am.getResponseBodyAsString();
603                 if (code == 201) {
604                         int startIndex = message.indexOf("jobs") + 6;
605                         int endIndex = message.length() - 2;
606                         String jobID = message.substring(startIndex, endIndex);
607                         svcLogic.setAttribute("org.openecomp.appc.jobID", jobID);
608                         logger.info(jobID);
609                 }
610                 chefServerResult(rc, Integer.toString(code), message);
611         }
612
613         
614         @SuppressWarnings("static-method")
615         private void doFailure(RequestContext rc, int code, String message) {
616                 SvcLogicContext svcLogic = rc.getSvcLogicContext();
617                 String msg = (message == null) ? Integer.toString(code) : message;
618                 if (msg.contains("\n")) {
619                         msg = msg.substring(msg.indexOf("\n"));
620                 }
621
622                 String status;
623                 try {
624                         status = Integer.toString(code);
625                 } catch (Exception e) {
626                         status = "500";
627                 }
628                 svcLogic.setAttribute("org.openecomp.appc.chefAgent.code", status);
629                 svcLogic.setAttribute("org.openecomp.appc.chefAgent.message", msg);
630         }
631
632         /**
633          * @param rc
634          *            The request context that manages the state and recovery of the
635          *            request for the life of its processing.
636          */
637
638         @SuppressWarnings("static-method")
639         private void doSuccess(RequestContext rc) {
640                 SvcLogicContext svcLogic = rc.getSvcLogicContext();
641                 svcLogic.setAttribute("org.openecomp.appc.chefAgent.code", "200");
642         }
643         
644         
645         @SuppressWarnings("static-method")
646         private void chefServerResult(RequestContext rc, String code ,String message) {
647                 String msg = (message == null) ? " " : message;
648                 SvcLogicContext svcLogic = rc.getSvcLogicContext();
649                 svcLogic.setStatus(OUTCOME_SUCCESS);
650                 svcLogic.setAttribute("org.openecomp.appc.chefServerResult.code", code);
651                 svcLogic.setAttribute("org.openecomp.appc.chefServerResult.message", message);
652         }
653
654         @SuppressWarnings("static-method")
655         private void chefClientResult(RequestContext rc, String code ,String message) {
656                 String msg = (message == null) ? " " : message;
657                 SvcLogicContext svcLogic = rc.getSvcLogicContext();
658                 svcLogic.setStatus(OUTCOME_SUCCESS);
659                 svcLogic.setAttribute("org.openecomp.appc.chefClientResult.code", code);
660                 svcLogic.setAttribute("org.openecomp.appc.chefClientResult.message", message);
661         }
662
663         /**
664          * initialize the provider adapter by building the context cache
665          */
666         private void initialize() {
667                 configuration = ConfigurationFactory.getConfiguration();
668                 //need to fetch data from appc configurator or form some file in the appc vms
669                 clientName="testnode";
670             clientPrivatekey="/etc/chef/client.pem";
671             serverAddress="http://example.com";
672             organizations="test";    
673                 chefserver=serverAddress+"/organizations/"+organizations;       
674                 logger.info("Initialize Chef Adapter");
675         }
676         
677         private void initialize(String key) {
678                 configuration = ConfigurationFactory.getConfiguration();
679                 //need to fetch data from appc configurator or form some file in the appc vms
680                 clientName="testnode";
681             clientPrivatekey=key;
682             serverAddress="http://example.com";
683             organizations="test";    
684                 chefserver=serverAddress+"/organizations/"+organizations;       
685                 logger.info("Initialize Chef Adapter");
686         }
687
688 }