@@ -0,0 +1,3208 @@
+package sonata.kernel.placement.net;%0A%0Aimport org.apache.commons.httpclient.HttpClient;%0Aimport org.apache.http.HttpResponse;%0Aimport org.apache.http.client.methods.CloseableHttpResponse;%0Aimport org.apache.http.client.methods.HttpGet;%0Aimport org.apache.http.impl.client.CloseableHttpClient;%0Aimport org.apache.http.impl.client.DefaultHttpClient;%0Aimport org.apache.http.impl.client.HttpClients;%0Aimport org.apache.log4j.Logger;%0Aimport sonata.kernel.placement.config.PopResource;%0A%0Aimport java.io.IOException;%0A%0Apublic class TranslatorChain %7B%0A%0A    final static Logger logger = Logger.getLogger(TranslatorChain.class);%0A%0A    public static void chain(PopResource popResource, String srcVnf, String srcInterface, String dstVnf, String dstInterface)%7B%0A%0A        String chainPath = getChainPath(popResource);%0A        String requestUri;%0A%0A        if(srcInterface == null %7C%7C dstInterface == null)%0A            requestUri = chainPath+%22/v1/chain/%22+srcVnf+%22/%22+dstVnf;%0A        else%0A            requestUri = chainPath+%22/v1/chain/%22+srcVnf+%22/%22+srcInterface+%22/%22+dstVnf+%22/%22+srcInterface;%0A%0A        CloseableHttpClient client = HttpClients.createDefault();%0A        HttpGet getRequest = new HttpGet(requestUri);%0A        CloseableHttpResponse response = null;%0A%0A        logger.info(%22Chaining %22+getRequest.getRequestLine().getUri());%0A%0A        try %7B%0A            response = client.execute(getRequest);%0A            if (response.getStatusLine().getStatusCode() == 500) %7B%0A                logger.error(%22Chaining failed %22+requestUri);%0A            %7D else %7B%0A                logger.info(%22Chaining successful %22+requestUri);%0A            %7D%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A            logger.error(%22Chaining request aborted %22+requestUri);%0A        %7D%0A    %7D%0A%0A    public static void unchain(PopResource popResource, String srcVnf, String dstVnf)%7B%0A        String chainPath = getChainPath(popResource);%0A%0A        CloseableHttpClient client = HttpClients.createDefault();%0A        String requestUri = chainPath+%22/v1/unchain/%22+srcVnf+%22/%22+dstVnf;%0A%0A        HttpGet getRequest = new HttpGet(requestUri);%0A        CloseableHttpResponse response = null;%0A%0A        logger.info(%22Unchaining %22+getRequest.getRequestLine().getUri());%0A%0A        try %7B%0A            response = client.execute(getRequest);%0A            if (response.getStatusLine().getStatusCode() == 500) %7B%0A                logger.error(%22Unchaining failed %22+requestUri);%0A            %7D else %7B%0A                logger.info(%22Unchaining successful %22+requestUri);%0A            %7D%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A            logger.error(%22Unchaining request aborted %22+requestUri);%0A        %7D%0A    %7D%0A%0A%0A%0A    protected static String getChainPath(PopResource popResource)%7B%0A        // TODO: replace string operations with a proper definition in the configuration file%0A        // infer chain path using keystone path%0A        String keystone = popResource.getEndpoint();%0A        int colonIndex = keystone.lastIndexOf(%22:%22);%0A        String host = keystone.substring(0,colonIndex);%0A        String portStr = keystone.substring(colonIndex+1);%0A        int port = Integer.parseInt(portStr);%0A%0A        String chainPath = host+%22:%22+(port-1000);%0A        return chainPath;%0A    %7D%0A%0A%7D%0A

Add Chaining api call