aboutsummaryrefslogtreecommitdiffstats
path: root/ncomp-docker-adaptor/src/main/java
diff options
context:
space:
mode:
authorCarsten Lund <lund@research.att.com>2017-04-16 14:12:28 +0000
committerCarsten Lund <lund@research.att.com>2017-04-16 14:12:43 +0000
commit572921972ce687527d6d60849eed8a55211b72ef (patch)
treee74d5e995595b104600eb59e168be8a6cdb38f26 /ncomp-docker-adaptor/src/main/java
parentcf6df0d665930d80aca05398e9262545eba7df83 (diff)
[DCAE-15] Changes related to version 1.1
See Jira for details Change-Id: Ic346dd5d5faf9816faa84eddb89f14654ea20156 Signed-off-by: Carsten Lund <lund@research.att.com>
Diffstat (limited to 'ncomp-docker-adaptor/src/main/java')
-rw-r--r--ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/docker/adaptor/tools/Generator.java5
-rw-r--r--ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/servers/docker/DockerAbstractClient.java8
-rw-r--r--ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/servers/docker/DockerDockerHostProvider.java27
-rw-r--r--ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/servers/docker/TestPolling.java5
4 files changed, 20 insertions, 25 deletions
diff --git a/ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/docker/adaptor/tools/Generator.java b/ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/docker/adaptor/tools/Generator.java
index 09f3f3f..2de12d8 100644
--- a/ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/docker/adaptor/tools/Generator.java
+++ b/ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/docker/adaptor/tools/Generator.java
@@ -45,12 +45,13 @@ public class Generator {
String dir = p.getNsURI().replaceAll(p.getNsPrefix() + '$', "") + "servers." + p.getNsPrefix();
dir = "src/main/sirius-gen/" + dir.replace('.', '/');
ControllerModel m = ControllermodelFactory.eINSTANCE.createControllerModel();
- m.setTemplateDirectory("../../dcae-org.openecomp.ncomp.sirius.manager/ncomp-sirius-manager-generator/src/main/templates");
+ m.setTemplateDirectory("../../ncomp.sirius.manager/ncomp-sirius-manager-generator/src/main/templates");
m.setPrefix("Docker");
m.setPluginName(p.getNsURI());
m.setName("Docker");
m.setTitle("Docker");
- ControllerGenerator g = new ControllerGenerator(o, m);
+ ControllerGenerator g = new ControllerGenerator(o, m);
+ g.setVersion("ONAP-R2");
EObject h = DockerFactory.eINSTANCE.createDockerHost();
g.addApi("host", h, m, false, true);
g.setEnableIRequestHandler(false);
diff --git a/ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/servers/docker/DockerAbstractClient.java b/ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/servers/docker/DockerAbstractClient.java
index 30a5777..2fc41a8 100644
--- a/ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/servers/docker/DockerAbstractClient.java
+++ b/ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/servers/docker/DockerAbstractClient.java
@@ -74,8 +74,8 @@ public abstract class DockerAbstractClient {
EOperation op = EUtils.name2operation(o.eClass(), opName);
if (op == null)
throw new RuntimeException("no such operation: " + opName + " on " + o);
- JSONObject res = operationPath2(path, opName, timeout, ManagementServer.params2json(op, params));
- return ManagementServer.json2response(op, res);
+ JSONObject res = operationPath2(path, opName, timeout, ManagementServer.params2json(op, params, "UNKNOWN"));
+ return ManagementServer.json2response(op, res, "UNKNOWN");
}
public JSONObject operation(String resourcePath, String opName, Long timeout, JSONObject json) {
@@ -96,14 +96,14 @@ public abstract class DockerAbstractClient {
throw new RuntimeException("Unknown operation " + opName + " on Eclass " + c.getName());
}
JSONObject res;
- JSONObject json1 = ManagementServer.params2json(op, params);
+ JSONObject json1 = ManagementServer.params2json(op, params, "UNKNOWN");
if (language != null && language.equals("restconf")) {
res = operationOdl("/restconf/operations/" + namespace + ":" + opName,timeout,json1);
}
else {
res = operationPath2(resourcePath, op.getName(), timeout, json1 );
}
- return ManagementServer.json2response(op, res);
+ return ManagementServer.json2response(op, res, "UNKNOWN");
}
// abstract public void sendToDataRouter(String feedname, String fileId,
diff --git a/ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/servers/docker/DockerDockerHostProvider.java b/ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/servers/docker/DockerDockerHostProvider.java
index d3888dc..8ea1ba9 100644
--- a/ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/servers/docker/DockerDockerHostProvider.java
+++ b/ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/servers/docker/DockerDockerHostProvider.java
@@ -40,7 +40,6 @@ import org.openecomp.ncomp.sirius.manager.ISiriusServer;
import org.openecomp.ncomp.sirius.manager.ManagementServer;
import org.openecomp.ncomp.sirius.manager.ManagementServerUtils;
-import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger;
import org.json.JSONArray;
import org.json.JSONObject;
@@ -63,6 +62,7 @@ import org.openecomp.ncomp.docker.DockerImage;
import org.openecomp.ncomp.docker.DockerNetwork;
import org.openecomp.ncomp.docker.DockerPackage;
+
import org.eclipse.emf.common.util.EList;
class DockerDockerHostProvider extends BasicAdaptorProvider {
@@ -102,11 +102,6 @@ class DockerDockerHostProvider extends BasicAdaptorProvider {
CREATE, START, STOP, RESTART, PAUSE, UNPAUSE, KILL, DESTORY
}
- private JSONObject encodeAuth(String json) {
- String auth = Base64.encodeBase64String(json.getBytes());
- return new JSONObject(auth);
- }
-
public DockerDockerHostProvider(ISiriusServer controller, DockerHost o) {
super(controller, o);
this.o = o;
@@ -405,9 +400,9 @@ class DockerDockerHostProvider extends BasicAdaptorProvider {
// EList<DockerProcess> cp = container.getProcesses();
// cp = (EList<DockerProcess>)Arrays.asList(dp);
- System.err.println("XXXX "
- + ManagementServer.ecore2json(container, 100, null, true)
- .toString(2));
+// System.err.println("XXXX "
+// + ManagementServer.ecore2json(container, 100, null, true)
+// .toString(2));
o.getContainers().add(container);
}
}
@@ -423,7 +418,7 @@ class DockerDockerHostProvider extends BasicAdaptorProvider {
fixNull(j);
rename(j, "created", "dockerCreated");
if (j.has("labels")) j.remove("labels");
- System.err.println("XXXX " + j.toString());
+// System.err.println("XXXX " + j.toString());
DockerImage image = (DockerImage) controller.getServer()
.json2ecore(DockerPackage.eINSTANCE.getDockerImage(), j);
// System.err.println("XXXX " + ManagementServer.ecore2json(image,
@@ -460,7 +455,7 @@ class DockerDockerHostProvider extends BasicAdaptorProvider {
JSONObject netwks = j.getJSONObject("networks");
for(String net : JSONObject.getNames(netwks)) {
JSONObject intf = netwks.getJSONObject(net);
- System.err.println(net + " <- " + intf.toString(4));
+// System.err.println(net + " <- " + intf.toString(4));
ContainerNetworkStats cnet = DockerFactory.eINSTANCE.createContainerNetworkStats();
cnet.setIntf(net);
cnet.setRx_bytes(intf.getInt("rx_bytes"));
@@ -484,7 +479,10 @@ class DockerDockerHostProvider extends BasicAdaptorProvider {
memusg.setUsage(mem.getInt("usage"));
memusg.setMax_usage(mem.getInt("max_usage"));
memusg.setLimit(mem.getInt("limit"));
- memusg.setFailcnt(mem.getInt("failcnt"));
+ try {
+ memusg.setFailcnt(mem.getInt("failcnt"));
+ } catch (Exception e) {
+ }
/*
* memory stats
@@ -551,6 +549,7 @@ class DockerDockerHostProvider extends BasicAdaptorProvider {
cstats.setCpu(ccpustats);
c.setStats(cstats);
+ controller.getServer().save();
}
}
@@ -616,7 +615,7 @@ class DockerDockerHostProvider extends BasicAdaptorProvider {
// System.err.println("XXXX " + v.getClass().getName());
if (v.getClass().getName().equals("org.json.JSONObject$Null")) {
j.put(k, new JSONArray());
- System.err.println("XXXX change null to empty array " + k);
+// System.err.println("XXXX change null to empty array " + k);
}
}
}
@@ -906,7 +905,7 @@ class DockerDockerHostProvider extends BasicAdaptorProvider {
// 404 - no such container
// 500 - server err
}
-
+
private List<String> getImageNameElements(String image) {
List<String> a = new ArrayList<>();
diff --git a/ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/servers/docker/TestPolling.java b/ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/servers/docker/TestPolling.java
index 450a41f..43f3910 100644
--- a/ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/servers/docker/TestPolling.java
+++ b/ncomp-docker-adaptor/src/main/java/org/openecomp/ncomp/servers/docker/TestPolling.java
@@ -24,11 +24,6 @@ package org.openecomp.ncomp.servers.docker;
import org.openecomp.ncomp.sirius.manager.ISiriusServer;
import org.openecomp.ncomp.sirius.manager.ManagementServer;
-/*
- * the polled docker-engine is defined in docker.properties
- * dockerHost.endpoint=https://host.domaon:port
- *
- */
public class TestPolling implements ISiriusServer {
public static void main(String[] args) {