@Override
public void vnfcEnvironment(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException {
int code;
- try {
- logger.info("environment of VNF-C");
- chefInfo(params, ctx);
- RequestContext rc = new RequestContext(ctx);
- logger.info("Context" + ctx);
- rc.isAlive();
- String env = params.get("Environment");
- logger.info("Environmnet" + env);
- if (env.equals(StringUtils.EMPTY)) {
- chefServerResult(rc, 200, "Skip Environment block ");
- } else {
- JSONObject envJ = new JSONObject(env);
- String envName = envJ.getString("name");
- String message;
- if (privateKeyChecker.doesExist(clientPrivatekey)) {
+ logger.info("environment of VNF-C");
+ chefInfo(params, ctx);
+ String env = params.get("Environment");
+ logger.info("Environmnet" + env);
+ if (env.equals(StringUtils.EMPTY)) {
+ chefServerResult(new RequestContext(ctx), 200, "Skip Environment block ");
+ } else {
+ String message;
+ if (privateKeyChecker.doesExist(clientPrivatekey)) {
+ try {
+ JSONObject envJ = new JSONObject(env);
+ String envName = envJ.getString("name");
// update the details of an environment on the Chef server.
ChefApiClient chefApiClient = chefApiClientFactory.create(chefserver, organizations, username, clientPrivatekey);
ChefResponse chefResponse = chefApiClient.put("/environments/" + envName, env);
message = chefResponse.getBody();
logger.info("requestbody {}", chefResponse.getBody());
}
-
- } else {
- code = 500;
- message = CANNOT_FIND_PRIVATE_KEY_STR + clientPrivatekey;
- doFailure(ctx, code, message);
+ chefServerResult(new RequestContext(ctx), code, message);
+ } catch (JSONException e) {
+ code = 401;
+ logger.error(POSTING_REQUEST_JSON_ERROR_STR, e);
+ doFailure(ctx, code, POSTING_REQUEST_JSON_ERROR_STR + e.getMessage());
+ } catch (Exception e) {
+ code = 401;
+ logger.error(POSTING_REQUEST_ERROR_STR, e);
+ doFailure(ctx, code, POSTING_REQUEST_ERROR_STR + e.getMessage());
}
- chefServerResult(rc, code, message);
+ } else {
+ code = 500;
+ message = CANNOT_FIND_PRIVATE_KEY_STR + clientPrivatekey;
+ doFailure(ctx, code, message);
}
- } catch (JSONException e) {
- code = 401;
- logger.error(POSTING_REQUEST_JSON_ERROR_STR, e);
- doFailure(ctx, code, POSTING_REQUEST_JSON_ERROR_STR + e.getMessage());
- } catch (Exception e) {
- code = 401;
- logger.error(POSTING_REQUEST_ERROR_STR, e);
- doFailure(ctx, code, POSTING_REQUEST_ERROR_STR + e.getMessage());
}
}