private String methodName = "GET";
public String test = "";
private int returnCode;
-// final String KEY_STORE_PATH = "/tmp/chef/trusted_certs/mykeystore.jks";
-// final String KEY_STORE_PASSWORD = "changeit";
public ApiMethod(String methodName) {
-/* try {
- SSLContext sslcontext = SSLContexts.custom()
- .loadTrustMaterial(new File(KEY_STORE_PATH), KEY_STORE_PASSWORD.toCharArray(),
- new TrustSelfSignedStrategy())
- .build();
- SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
- sslcontext,
- new String[] { "TLSv1" },
- null,
- SSLConnectionSocketFactory.getDefaultHostnameVerifier());
- client = HttpClients.custom()
- .setSSLSocketFactory(sslsf)
- .build();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }*/
client=HttpClients.createDefault();
this.methodName = methodName;
}
for (int i = 0; i < auth_headers.length; i++) {
method.addHeader("X-Ops-Authorization-" + (i + 1), auth_headers[i]);
}
- /*
- * test=test+this.method.getMethod()+"\n"; Header[]
- * RHS=this.method.getHeaders(); for (int i = 0; i < RHS.length; i++) {
- * test=test+RHS[i]+"\n"; } test=test+this.reqBody+"\n";
- */
try{
response = client.execute(method);
resCode = response.getStatusLine().getStatusCode();
put.setChefPath(path);
return put;
}
-/* public Post post(String path){
- Post post = new Post(new PostMethod(endpoint+path));
- post.setPemPath(pemPath);
- post.setUserId(userId);
- return post;
- }
-
- public Delete delete(String path){
- Delete del = new Delete(new DeleteMethod(endpoint+path));
- del.setPemPath(pemPath);
- del.setUserId(userId);
- return del;
- }
-
-
-*/
-/* public Header[] buildHeaders(){
-
- return null;
- }
-*/
}
*/
private Configuration configuration;
- /**
- * A cache of providers that are predefined.
- */
- // private Map<String /* provider name */, ProviderCache> providerCache;
-
/**
* This default constructor is used as a work around because the activator
* wasnt getting called
public void chefGet(Map<String, String> params, SvcLogicContext ctx) {
logger.info("chef get method");
String chefAction= params.get("org.openecomp.appc.instance.chefAction");
- // logger.info(vm_url);
RequestContext rc = new RequestContext(ctx);
rc.isAlive();
//should load pem from somewhere else
String message = am.getResponseBodyAsString();
logger.info(code + " " + message);
chefServerResult(rc,Integer.toString(code),message);
-/* if (code == 200) {
- doSuccess(rc);
- } else {
- String errorcode=code+" ";
- doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, errorcode);
- }*/
-
}
/**
@Override
public void chefPut(Map<String, String> params, SvcLogicContext ctx) {
- //String tVmIp = params.get("org.openecomp.appc.instance.ip");
- //logger.info(tVmIp);
logger.info("chef PUT method");
logger.info(clientName+" "+clientPrivatekey+" "+chefserver+" "+organizations);
- //String CHEF_NODE_STR= params.get("org.openecomp.appc.instance.chefRequestBody");
String chefAction= params.get("org.openecomp.appc.instance.chefAction");
String runList= params.get("org.openecomp.appc.instance.runList");
String attributes= params.get("org.openecomp.appc.instance.attributes");
logger.info(attributes);
- //attributes="\"reconfig-test\":{\"secret\":\"newpass2\"}";
String CHEF_NODE_STR = "{\"json_class\":\"Chef::Node\",\"default\":{},\"chef_type\":\"node\",\"run_list\":[\""+runList+"\"],\"override\":{},\"automatic\":{},\"normal\":{"+attributes+"},\"name\":\"testnode\",\"chef_environment\":\"_default\"}";
- //String CHEF_NODE_STR = "{\"json_class\":\"Chef::Node\"}";
- // logger.info(vm_url);
RequestContext rc = new RequestContext(ctx);
rc.isAlive();
//should load pem from somewhere else
String message = am.getResponseBodyAsString();
logger.info(code + " " + message);
chefServerResult(rc,Integer.toString(code),message);
-/* if (code == 200) {
- logger.info("chef PUT method success");
- doSuccess(rc);
- } else {
- String errorcode=code+" ";
- logger.info("chef PUT method failure");
- doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, errorcode);
- }*/
-
}
public void trigger(Map<String, String> params, SvcLogicContext ctx) {
logger.info("Run trigger method");
String tVmIp = params.get("org.openecomp.appc.instance.ip");
- //String tUrl = "http://" + tVmIp;
RequestContext rc = new RequestContext(ctx);
rc.isAlive();
<features name="appc-chef-adapter-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
-
-<!-- <repository>mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.version}/xml/features</repository> -->
+
<repository>mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features</repository>
<feature name='appc-chef-adapter' description="appc-chef-adapter" version='${project.version}'>
@Override
public void start(final BundleContext bundleContext) throws Exception {
LOG.info("Starting Bundle " + getName());
-
- /* if (registration == null) {
- Properties properties = ConfigurationFactory.getConfiguration().getProperties();
- registration = bundleContext.registerService(EventSender.class, new EventSenderImpl(properties), null);
- }*/
}
/**
*/
@Override
public void stop(BundleContext ctx) throws Exception {
- /*if (this.registration != null) {
- this.registration.unregister();
- }*/
LOG.info("Stopped Bundle " + getName());
}
*/
void configure(String configuration, String deviceMountPointName, String moduleName, String nodeName) throws APPCException;
- /*
- backup device configuration
- @param deviceMountPointName - the name of the mounting point in controlle
- */
- //void backupConfiguration(String deviceMountPointName);
/*
returns configuration of Netconf server
@param deviceMountPointName - the name of the mounting point in controller
LOG.debug("Sending message to netconf device:\n" + text);
}
pipedOutIn.write(new NetconfMessage(text).getFrame());
-// pipedOutIn.flush();
}
}
private Session session;
private Channel channel;
private NetconfAdapter netconfAdapter;
-// private NetconfAdapter2 netconfAdapter;
@Override
channel = session.openChannel("subsystem");
((ChannelSubsystem)channel).setSubsystem("netconf");
netconfAdapter = new NetconfAdapter(channel.getInputStream(), channel.getOutputStream());
-// netconfAdapter = new NetconfAdapter2();
-// channel.setInputStream(netconfAdapter.getIn());
-// channel.setOutputStream(netconfAdapter.getOut());
channel.connect(CHANNEL_CONNECT_TIMEOUT);
hello(connectionDetails.getCapabilities());
} catch(Exception e) {
private Constants(){}
-// public static final String CONFIGURE_PATH = "/restconf/config/opendaylight-inventory:nodes/node/";
-// public static final String CONNECT_PATH = "/restconf/config/opendaylight-inventory:nodes/node/controller-config/yang-ext:mount/config:modules";
-// public static final String CHECK_CONNECTION_PATH = "/restconf/operational/opendaylight-inventory:nodes/node/";
-// public static final String DISCONNECT_PATH = "/restconf/config/opendaylight-inventory:nodes/node/controller-config/yang-ext:mount/config:modules/module/odl-sal-netconf-connector-cfg:sal-netconf-connector/";
-//
-// public static final String CONTROLLER_IP = "127.0.0.1";
-// public static final int CONTROLLER_PORT = 8181;
-// public static final String PROTOCOL = "http";
-//
-// public static final String VF_LICENSE = "VF_LICENSE";
-
// tables and fields
public static final String NETCONF_SCHEMA = "sdnctl";
public static final String SDNCTL_SCHEMA = "sdnctl";
// constants fo DG
-// public static final String VNF_TYPE_FIELD_NAME = "org.openecomp.appc.vftype";
-// public static final String VNF_VERSION_FIELD_NAME = "org.openecomp.appc.vfversion";
-// public static final String VNF_RESOURCE_VERSION_FIELD_NAME = "org.openecomp.appc.resource-version";
-// public static final String TARGET_VNF_TYPE = "target-vnf-type";
-// public static final String FILE_CONTENT_FIELD_NAME = "file-content";
public static final String CONNECTION_DETAILS_FIELD_NAME = "connection-details";
-// public static final String CONFIGURATION_FILE_FIELD_NAME = "configuration-file-name";
public static final String VNF_HOST_IP_ADDRESS_FIELD_NAME = "vnf-host-ip-address";
-// public static final String UPGRADE_VERSION = "upgrade-version";
public static final String DG_ERROR_FIELD_NAME = "org.openecomp.appc.dg.error";
-// public static final String RESOURCEKEY = "resourceKey";
-// public static final String REQ_ID_FIELD_NAME = "org.openecomp.appc.reqid";
-// public static final String API_VERSION_FIELD_NAME = "org.openecomp.appc.apiversion";
-// public static final String MODEL_ENTITLMENT_POOL_UUID_NAME = "model.entitlement.pool.uuid";
-// public static final String MODEL_LICENSE_KEY_UUID_NAME = "model.license.key.uuid";
-// public static final String ENTITLMENT_POOL_UUID_NAME = "entitlement.pool.uuid";
-// public static final String LICENSE_KEY_UUID_NAME = "license.key.uuid";
-// public static final String IS_ACQUIRE_LICENSE_REQUIRE ="is.acquire-license.require";
-// public static final String IS_RELEASE_LICENSE_REQUIRE ="is.release-license.require";
-//
-// public static final String AAI_ENTITLMENT_POOL_UUID_NAME = "aai.input.data.entitlement-assignment-group-uuid";
-// public static final String AAI_LICENSE_KEY_UUID_NAME = "aai.input.data.license-assignment-group-uuid";
-// public static final String AAI_LICENSE_KEY_VALUE = "aai.input.data.license-key";
-// public static final String IS_AAI_ENTITLEMENT_UPDATE_REQUIRE = "is.aai-entitlement-update.require";
-// public static final String IS_AAI_LICENSE_UPDATE_REQUIRE = "is.aai-license-update.require";
-// public static final String IS_ACQUIRE_ENTITLEMENT_REQUIRE ="is.acquire-entitlement.require";
-// public static final String IS_RELEASE_ENTITLEMENT_REQUIRE ="is.release-entitlement.require";
-//
-// public enum ASDC_ARTIFACTS_FIELDS {
-// SERVICE_UUID,
-// DISTRIBUTION_ID,
-// SERVICE_NAME,
-// SERVICE_DESCRIPTION,
-// RESOURCE_UUID,
-// RESOURCE_INSTANCE_NAME,
-// RESOURCE_NAME,
-// RESOURCE_VERSION,
-// RESOURCE_TYPE,
-// ARTIFACT_UUID,
-// ARTIFACT_TYPE,
-// ARTIFACT_VERSION,
-// ARTIFACT_DESCRIPTION,
-// INTERNAL_VERSION,
-// CREATION_DATE,
-// ARTIFACT_NAME,
-// ARTIFACT_CONTENT
-// }
}
*/
@SuppressWarnings("nls")
private EncryptionTool() {
- // encryptor = new BasicTextEncryptor();
- // encryptor.setPassword(secret.toString());
String out = "Found the following security algorithms:";
for (Provider p : Security.getProviders()) {
for (Service s : p.getServices()) {
public synchronized String decrypt(String cipherText) {
if (isEncrypted(cipherText)) {
String encValue = cipherText.substring(ENCRYPTED_VALUE_PREFIX.length());
- // return encryptor.decrypt(encValue);
byte[] plainByte = Base64.decodeBase64(encValue.getBytes());
byte[] decryptByte = xorWithSecret(plainByte);
return new String(decryptByte);
writeLock.unlock();
}
- // return obj;
-
/*
* Now that we have the real object, lets wrap it in a dynamic proxy so that we can intercept the close call and
* just return the context to the free pool. obj.getClass().getInterfaces(). We need to find ALL interfaces that
for (Map.Entry<String, Object> entry : params.entrySet()) {
formattedMessage = formattedMessage.replaceAll("\\$\\{" + entry.getKey() + "\\}", String.valueOf(entry.getValue()));
}
-/* } else {
- StringBuilder builder = new StringBuilder(formattedMessage);
- builder.append("; output params: [");
- for (Map.Entry<String, Object> entry : params.entrySet()) {
- builder.append(entry.getKey()).append(":").append(String.valueOf(entry.getValue())).append("; ");
- }
- builder.append("]");
- formattedMessage = builder.toString();*/
}
return formattedMessage;
private static final EELFLogger logger = EELFManager.getInstance().getLogger(ExecuteNodeActionImpl.class);
public ExecuteNodeActionImpl() {
- // getAAIservice();
}
/**
client.connect(connectionDetails);
String configuration = client.getConfiguration();
if(configuration !=null){
- // logger.info("*************************************Configuration Output*************************************");
- // logger.info(configuration);
String fullConfig = ctx.getAttribute("fullConfig");
fullConfig = fullConfig==null?"":fullConfig;
ctx.setAttribute("fullConfig",fullConfig + configuration);
}else{
ctx.setAttribute("getConfig_Result","failure");
}
- //store configuration in database
- /*NetconfJDBC dsImpl = new NetconfJDBCImpl();
- dsImpl.logDeviceInteraction(null,null,getCurrentDateTime(),configuration);*/
-
} catch (Exception e) {
ctx.setAttribute("getConfig_Result","failure");
logger.error("Error " + e.getMessage());
logger.error("Missing configuration for " + params.get(Constants.VNF_TYPE_FIELD_NAME));
throw new APPCException("Missing configuration for " + params.get(Constants.VNF_TYPE_FIELD_NAME) + " in " + Constants.DEVICE_AUTHENTICATION_TABLE_NAME);
}
- // fileContent = dsImpl.retrieveConfigFileName(params.get(Constants.CONFIGURATION_FILE_FIELD_NAME));
- // ctx.setAttribute(Constants.FILE_CONTENT_FIELD_NAME, fileContent);
ctx.setAttribute(Constants.CONNECTION_DETAILS_FIELD_NAME, mapper.writeValueAsString(connectionDetails));
ctx.setAttribute("retrieveVMDSConfiguration_Result","success");
} catch(APPCException e) {
*/
String PARAM_IN_command = "command";
- /*
- String PARAM_IN_host = "host";
- String PARAM_IN_port = "port";
- String PARAM_IN_username = "username";
- String PARAM_IN_password = "password";
- */
-
/**
* Input parameter for SSH command timeout
*/
public class CommandTaskFactory {
-
-// private LCMCommandTask lcmCommandTask;
-// private LCMReadonlyCommandTask LCMReadonlyCommandTask;
-
private RequestHandler requestHandler;
private WorkFlowManager workflowManager;
private LifecycleManager lifecyclemanager;
return clearFlag;
}
-
- /*public static DbLibService getDBLibService(){
- DbLibService dblibSvc = null;
- BundleContext bctx = FrameworkUtil.getBundle(SvcLogicDblibStore.class).getBundleContext();
- ServiceReference sref = bctx.getServiceReference("org.openecomp.sdnc.sli.resource.dblib.DBResourceManager");
- if (sref == null) {
-// LOG.warn("Could not find service reference for DBLIB service (org.openecomp.sdnc.sli.resource.dblib.DBResourceManager)");
- }
- else {
- dblibSvc = (DbLibService)bctx.getService(sref);
- if (dblibSvc == null)
- {
-// LOG.warn("Could not find service reference for DBLIB service (org.openecomp.sdnc.sli.resource.dblib.DBResourceManager)");
- }
- }
- return dblibSvc;
- }*/
}
State STOPPING = new State(VNFStates.Stopping.toString());
State STOPPED = new State(VNFStates.Stopped.toString());
-// State PRE_UPGRADE_TESTING = new State(VNFStates.Pre_Upgrade_Testing.toString());
State BACKING_UP = new State(VNFStates.Backing_Up.toString());
State SNAPSHOTTING = new State(VNFStates.Snapshotting.toString());
State SOFTWARE_UPLOADING = new State(VNFStates.Software_Uploading.toString());
builder = builder.addState(TERMINATING);
builder = builder.addState(STOPPING);
builder = builder.addState(STOPPED);
-// builder = builder.addState(PRE_UPGRADE_TESTING);
builder = builder.addState(BACKING_UP);
builder = builder.addState(SNAPSHOTTING);
builder = builder.addState(SOFTWARE_UPLOADING);
builder = builder.addTransition(STOPPING,SUCCESS,STOPPED);
builder = builder.addTransition(STOPPING,FAILURE,ERROR);
-// builder = builder.addTransition(PRE_UPGRADE_TESTING,SUCCESS,TESTED);
-// builder = builder.addTransition(PRE_UPGRADE_TESTING,FAILURE,ERROR);
-
builder = builder.addTransition(BACKING_UP,SUCCESS,RUNNING);
builder = builder.addTransition(BACKING_UP,FAILURE,ERROR);
private String apiKey;
private String apiSecret;
- private Integer READ_TIMEOUT;
-
private static final EELFLogger logger = EELFManager.getInstance().getLogger(MessageAdapterDmaapImpl.class);
/**
}
pool = new HashSet<>();
if (props != null) {
- // readTopic = props.getProperty("dmaap.topic.read");
writeTopic = props.getProperty("dmaap.topic.write");
apiKey = props.getProperty("dmaap.client.key");
apiSecret = props.getProperty("dmaap.client.secret");
- /* clientName = props.getProperty("dmaap.client.name", "APP-C");
- clientId = props.getProperty("dmaap.client.name.id", "0");
- filter_json = props.getProperty("dmaap.topic.read.filter");
- */
- // READ_TIMEOUT = Integer.valueOf(props.getProperty("dmaap.topic.read.timeout", String.valueOf(READ_TIMEOUT)));
String hostnames = props.getProperty("dmaap.poolMembers");
if (hostnames != null && !hostnames.isEmpty()) {
for (String name : hostnames.split(",")) {
Action action = Action.valueOf(vnfOperation.name());
CommonHeader commonHeader = convAsyncResponseTorev160108CommonHeader(response);
Status status = convAsyncResponseTorev160108Status(response);
-// Payload payload = convAsyncResponseTorev160108Payload(inObj);
switch (action){
case Rollback:
outObj = new RollbackOutputBuilder();
if (logger.isTraceEnabled()) {
logger.trace("Entering to postMessageToDMaaP with AsyncResponse = " + ObjectUtils.toString(responseContext));
}
- /*boolean updated = updateAsyncResponseStatus(responseContext, isTTLEnd, aaiUpdateSuccess);
- */
boolean callbackResponse = messageAdapter.post(operation, rpcName, responseContext);
if (!callbackResponse) {
logger.error("DMaaP posting status: " + callbackResponse, "dmaapMessage: " + responseContext);
logger.trace("Exiting from postMessageToDMaaP with (callbackResponse = " + ObjectUtils.toString(callbackResponse) + ")");
}
- //returns true if asyncResponse was modified
- /* private boolean updateAsyncResponseStatus(ResponseContext asyncResponse, boolean isTTLEnd, boolean aaiUpdateSuccess) {
- boolean updated = false;
- if (logger.isTraceEnabled())
- logger.trace("Entering to updateAsyncResponseStatus with AsyncResponse = "+ObjectUtils.toString(asyncResponse)+ ", isTTLEnd = "+ ObjectUtils.toString(isTTLEnd)+ ", aaiUpdateSuccess = "+ ObjectUtils.toString(aaiUpdateSuccess));
- if(!aaiUpdateSuccess){
- if (asyncResponse.getStatus().getCode() == 0 || asyncResponse.getStatus().getCode() == LCMCommandStatus.SUCCESS.getResponseCode()) {
- asyncResponse.getStatus().setCode(LCMCommandStatus.UPDATE_AAI_FAILURE.getResponseCode());
- asyncResponse.getStatus().setMessage(LCMCommandStatus.UPDATE_AAI_FAILURE.getResponseMessage());
- updated = true;
- }
- }else if(isTTLEnd){
- asyncResponse.getStatus().setCode(LCMCommandStatus.EXPIRED_REQUEST_FAILURE.getResponseCode());
- asyncResponse.getStatus().setMessage(LCMCommandStatus.EXPIRED_REQUEST_FAILURE.getResponseMessage());
- updated = true;
- }
- if (logger.isTraceEnabled())
- logger.trace("Exiting from updateAsyncResponseStatus with (asyncResponse = "+ ObjectUtils.toString(asyncResponse)+")");
- return updated;
- }*/
-
-
/**
* This method perform following operations required if TTL ends when request still waiting in execution queue .
* It posts asynchronous response to message bus (DMaaP).
Properties props = configuration.getProperties();
Set<ListenerProperties> listeners = new HashSet<ListenerProperties>();
-
- // Configure App-C Closed Loop Listener
-/* ListenerProperties clProps = new ListenerProperties("appc.ClosedLoop", props);
- clProps.setListenerClass(org.openecomp.appc.listener.CL.impl.ListenerImpl.class);
- listeners.add(clProps);*/
// Configure App-C 1607 Closed Loop Listener
ListenerProperties cl1607Props = new ListenerProperties("appc.ClosedLoop1607", props);
cl1607Props.setListenerClass(org.openecomp.appc.listener.CL1607.impl.ListenerImpl.class);
- listeners.add(cl1607Props);
-
-
-/* ListenerProperties clLCMProps = new ListenerProperties("appc.LCM", props);
- clLCMProps.setListenerClass(org.openecomp.appc.listener.LCM.impl.ListenerImpl.class);
- listeners.add(clLCMProps);*/
-
-/*
- ListenerProperties clLCMProps1607 = new ListenerProperties("appc.LCM1607", props);
- clLCMProps1607.setListenerClass(org.openecomp.appc.listener.LCM1607.impl.ListenerImpl.class);
- listeners.add(clLCMProps1607);
-*/
+ listeners.add(cl1607Props);
adapter = new ControllerImpl(listeners);
if (ctx != null && registration == null) {
VnfResource vnf = input.getVnfResource();
TopologyService topology = new TopologyService(this);
- // RpcResult<RestartOutput> result = topology.restart(hdr, vnf);
- return null;// Futures.immediateFuture(result);
+ return null;
}
/**
LOG.debug("Parameters returned by SLI: " + StringHelper.propertiesToString(respProps));
metricsLogger.info("Parameters returned by SLI: " + StringHelper.propertiesToString(respProps));
- // No impact on flow. Not sure why it is here
- // if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) { return (respProps); }
-
return respProps;
}
}