aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dcae-controller-core/dcae-controller-operation-utils/src/main/java/org/openecomp/dcae/controller/operation/utils/DocUtils.java502
-rw-r--r--dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/servers/controller/inventory/DcaeDcaeInventoryTest.java24
-rw-r--r--dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerCluster.java208
-rw-r--r--dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerVirtualMachineService.java790
-rw-r--r--dcae-controller-service-cdap/dcae-controller-service-cdap-cluster/dcae-controller-service-cdap-cluster-manager/src/main/java/org/openecomp/dcae/controller/service/cdap/cluster/servers/manager/DcaeCdapClusterManagerProvider.java2
-rw-r--r--dcae-controller-service-cdap/dcae-controller-service-cdap-cluster/dcae-controller-service-cdap-cluster-manager/src/main/sirius-gen/org/openecomp/dcae/controller/service/cdap/cluster/servers/manager/DcaeCdapClusterManagerConsole.java1229
-rw-r--r--dcae-controller-service-docker/dcae-controller-service-docker-adaptor/src/main/java/org/openecomp/dcae/controller/service/servers/docker/DcaeDockerServiceProvider.java579
-rw-r--r--dcae-controller-service-docker/dcae-controller-service-docker-adaptor/src/main/java/org/openecomp/dcae/controller/service/servers/dockermanager/DcaeDockerManagerProvider.java241
-rw-r--r--dcae-controller-service-vm/dcae-controller-service-vm-adaptor/src/main/java/org/openecomp/dcae/controller/service/servers/vm/DcaeVirtualMachineServiceProvider.java1646
9 files changed, 2592 insertions, 2629 deletions
diff --git a/dcae-controller-core/dcae-controller-operation-utils/src/main/java/org/openecomp/dcae/controller/operation/utils/DocUtils.java b/dcae-controller-core/dcae-controller-operation-utils/src/main/java/org/openecomp/dcae/controller/operation/utils/DocUtils.java
index 7b30cf5..57d22bd 100644
--- a/dcae-controller-core/dcae-controller-operation-utils/src/main/java/org/openecomp/dcae/controller/operation/utils/DocUtils.java
+++ b/dcae-controller-core/dcae-controller-operation-utils/src/main/java/org/openecomp/dcae/controller/operation/utils/DocUtils.java
@@ -18,292 +18,314 @@
* limitations under the License.
* ============LICENSE_END============================================
*/
-
+
package org.openecomp.dcae.controller.operation.utils;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.openecomp.ncomp.utils.maps.CounterMap;
+import org.openecomp.ncomp.webservice.utils.JsonUtils;
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
-
-import org.openecomp.ncomp.utils.maps.CounterMap;
-import org.openecomp.ncomp.webservice.utils.JsonUtils;
-
import static org.openecomp.ncomp.sirius.manager.console.Utils.*;
public class DocUtils {
- protected String env;
- protected static String root = "/home/vagrant/git/org.openecomp.dcae.controller.operation";
- protected String release;
+ protected String env;
+ protected static String root = "/home/vagrant/git/org.openecomp.dcae.controller.operation";
+ protected String release;
// public DocUtils(String release, String env) {
// super();
// this.release = release;
// this.env = env;
// }
-
- public DocUtils(String release, String env, String root1, String root2) {
- super();
- this.release = release;
- this.env = env;
- if (root1 != null) root = root1;
- }
+
+ public DocUtils(String release, String env, String root1, String root2) {
+ super();
+ this.release = release;
+ this.env = env;
+ if (root1 != null) {
+ root = root1;
+ }
+ }
- @SuppressWarnings("rawtypes")
- public Map tenants() {
- String fileName = release + "-" + env + "/tenants.yaml";
- Map o = (Map) file2object(fileName);
- return o;
- }
+ @SuppressWarnings("rawtypes")
+ public Map tenants() {
+ String fileName = release + "-" + env + "/tenants.yaml";
+ Map o = (Map) file2object(fileName);
+ return o;
+ }
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public Map vms() {
- LinkedHashMap<String,LinkedHashMap<String,Object>> s = new LinkedHashMap<String,LinkedHashMap<String,Object>>();
- LinkedHashMap<String,LinkedHashMap<String,Object>> ss = new LinkedHashMap<String,LinkedHashMap<String,Object>>();
- CounterMap<String> index = new CounterMap<String>();
- Map<String,Object> locationTypes = locationTypes();
- Map<String,Object> vmTypes = (Map<String, Object>) types("vm");
- Map<String,Object> tenants = tenants();
- for (String t : locationTypes.keySet()) {
- for (String tenantKey : tenants.keySet()) {
- Map<String,Object> tenant = (Map<String, Object>) tenants.get(tenantKey);
- if (! t.equals(tenant.get("type"))) continue;
- Map<String,Object> locationType = (Map<String, Object>) locationTypes.get(t);
- Map<String,Object> vmDeployments = (Map<String, Object>) locationType.get("vm-deployments");
- for (String vmDeploymentKey : vmDeployments.keySet()) {
- Map<String,Object> vmDeployment = (Map<String, Object>) vmDeployments.get(vmDeploymentKey);
- Map<String,Object> vmType = (Map<String, Object>) vmTypes.get(vmDeployment.get("vm-type"));
- if (s.get(vmDeploymentKey) == null) {
- LinkedHashMap<String,Object> s1 = new LinkedHashMap<String,Object>();
- s.put(vmDeploymentKey, s1);
- s1.put("vm-type", vmDeployment.get("vm-type"));
- s1.put("release", vmDeployment.get("release"));
- s1.put("milestone", vmDeployment.get("milestone"));
- boolean useController = (Boolean) get(vmType,"lifecycle-management", "use-dcae-manager",new Boolean(false));
- s1.put("use-controller", useController);
- LinkedHashMap<String,Object> s2 = new LinkedHashMap<String,Object>();
- s1.put("locations", s2);
- ss.put(vmDeploymentKey, s2);
- }
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public Map vms() {
+ LinkedHashMap<String, LinkedHashMap<String, Object>> s = new LinkedHashMap<String, LinkedHashMap<String, Object>>();
+ LinkedHashMap<String, LinkedHashMap<String, Object>> ss = new LinkedHashMap<String, LinkedHashMap<String, Object>>();
+ CounterMap<String> index = new CounterMap<String>();
+ Map<String, Object> locationTypes = locationTypes();
+ Map<String, Object> vmTypes = (Map<String, Object>) types("vm");
+ Map<String, Object> tenants = tenants();
+ for (String t : locationTypes.keySet()) {
+ for (String tenantKey : tenants.keySet()) {
+ Map<String, Object> tenant = (Map<String, Object>) tenants.get(tenantKey);
+ if (!t.equals(tenant.get("type"))) {
+ continue;
+ }
+ Map<String, Object> locationType = (Map<String, Object>) locationTypes.get(t);
+ Map<String, Object> vmDeployments = (Map<String, Object>) locationType.get("vm-deployments");
+ for (String vmDeploymentKey : vmDeployments.keySet()) {
+ Map<String, Object> vmDeployment = (Map<String, Object>) vmDeployments.get(vmDeploymentKey);
+ Map<String, Object> vmType = (Map<String, Object>) vmTypes.get(vmDeployment.get("vm-type"));
+ if (s.get(vmDeploymentKey) == null) {
+ LinkedHashMap<String, Object> s1 = new LinkedHashMap<String, Object>();
+ s.put(vmDeploymentKey, s1);
+ s1.put("vm-type", vmDeployment.get("vm-type"));
+ s1.put("release", vmDeployment.get("release"));
+ s1.put("milestone", vmDeployment.get("milestone"));
+ boolean useController = (Boolean) get(vmType, "lifecycle-management", "use-dcae-manager", new Boolean(false));
+ s1.put("use-controller", useController);
+ LinkedHashMap<String, Object> s2 = new LinkedHashMap<String, Object>();
+ s1.put("locations", s2);
+ ss.put(vmDeploymentKey, s2);
+ }
// System.err.println (" XXx:" + t + " " + vmDeploymentKey + " " + vmTypes.keySet()+ " " + vmDeployment.get("vm-type"));
// if (vmType.containsKey("error")) continue;
- if (vmType == null) {
-
- }
- Integer numVms = (Integer) vmType.get("number-vms-per-location");
- if (numVms == null) numVms = 2;
+ if (vmType == null) {
+ continue;
+ }
+ Integer numVms = (Integer) vmType.get("number-vms-per-location");
+ if (numVms == null) {
+ numVms = 2;
+ }
// System.err.println (" XXx:" + t + " " + vmDeploymentKey + " " + vmType.keySet()+ " " + tenant.keySet());
- LinkedHashMap<String,Object> s1 = new LinkedHashMap<String,Object>();
- LinkedHashMap<String,Object> sss = new LinkedHashMap<String,Object>();
- s1.put("dcae-service", vmDeploymentKey);
- s1.put("dcae-service-instance", tenantKey);
- s1.put("dcae-container", "/locations/" + tenantKey);
- LinkedHashMap<String,Object> s2 = new LinkedHashMap<String,Object>();
- s1.put("vms", s2);
- String shortName = short_name(vmDeployment.get("vm-type"));
- String indexKey = tenant.get("name-short") + ":" + shortName;
- numVms = (Integer) vmType.get("number-vms-per-location");
- if (numVms == null) numVms = 2;
- for (int i = 0 ; i < numVms; i++) {
- String name = vmname(tenant,vmType,index.get(indexKey));
+ LinkedHashMap<String, Object> s1 = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> sss = new LinkedHashMap<String, Object>();
+ s1.put("dcae-service", vmDeploymentKey);
+ s1.put("dcae-service-instance", tenantKey);
+ s1.put("dcae-container", "/locations/" + tenantKey);
+ LinkedHashMap<String, Object> s2 = new LinkedHashMap<String, Object>();
+ s1.put("vms", s2);
+ String shortName = short_name(vmDeployment.get("vm-type"));
+ String indexKey = tenant.get("name-short") + ":" + shortName;
+ numVms = (Integer) vmType.get("number-vms-per-location");
+ if (numVms == null) {
+ numVms = 2;
+ }
+ for (int i = 0; i < numVms; i++) {
+ String name = vmname(tenant, vmType, index.get(indexKey));
// System.err.println ("new VM: " + name + " " + index.get(indexKey));
- index.increment(indexKey);
- LinkedHashMap<String,Object> s3 = new LinkedHashMap<String,Object>();
- s3.put("dns-name", name + "." + tenant.get("dns-surfix"));
- s2.put(name, s3);
- }
- ss.get(vmDeploymentKey).put(vmDeploymentKey+"-"+tenantKey, s1);
- }
- }
- }
- return s;
- }
-
- private String short_name(Object object) {
- String fileName = release + "/vm-templates/" + object + ".yaml";
- Map o = (Map) file2object(fileName);
- return (String) o.get("short-name");
- }
+ index.increment(indexKey);
+ LinkedHashMap<String, Object> s3 = new LinkedHashMap<String, Object>();
+ s3.put("dns-name", name + "." + tenant.get("dns-surfix"));
+ s2.put(name, s3);
+ }
+ ss.get(vmDeploymentKey).put(vmDeploymentKey + "-" + tenantKey, s1);
+ }
+ }
+ }
+ return s;
+ }
- Map<String,Object> locationTypes() {
- String fileName = release + "/location-types.yaml";
- @SuppressWarnings("unchecked")
- Map<String,Object> locationTypes = (Map) file2object(fileName);
- return locationTypes;
- }
+ private String short_name(Object object) {
+ String fileName = release + "/vm-templates/" + object + ".yaml";
+ Map o = (Map) file2object(fileName);
+ return (String) o.get("short-name");
+ }
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public Map dockers() {
- LinkedHashMap<String,Object> s = new LinkedHashMap<String,Object>();
- Map<String,Object> locationTypes = locationTypes();
- Map<String,Object> dockerTypes = (Map<String, Object>) types("docker");
- Map<String,Object> tenants = tenants();
- for (String t : locationTypes.keySet()) {
- for (String tenantKey : tenants.keySet()) {
- Map<String,Object> tenant = (Map<String, Object>) tenants.get(tenantKey);
- if (! t.equals(tenant.get("type"))) continue;
- Map<String,Object> locationType = (Map<String, Object>) locationTypes.get(t);
- Map<String,Object> dockerDeployments = (Map<String, Object>) locationType.get("docker-deployments");
- if (dockerDeployments == null) continue;
- for (String dockerDeploymentKey : dockerDeployments.keySet()) {
- Map<String,Object> dockerDeployment = (Map<String, Object>) dockerDeployments.get(dockerDeploymentKey);
- Map<String,Object> dockerType = (Map<String, Object>) dockerTypes.get(dockerDeployment.get("docker-type"));
+ Map<String, Object> locationTypes() {
+ String fileName = release + "/location-types.yaml";
+ @SuppressWarnings("unchecked")
+ Map<String, Object> locationTypes = (Map) file2object(fileName);
+ return locationTypes;
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public Map dockers() {
+ LinkedHashMap<String, Object> s = new LinkedHashMap<String, Object>();
+ Map<String, Object> locationTypes = locationTypes();
+ Map<String, Object> dockerTypes = (Map<String, Object>) types("docker");
+ Map<String, Object> tenants = tenants();
+ for (String t : locationTypes.keySet()) {
+ for (String tenantKey : tenants.keySet()) {
+ Map<String, Object> tenant = (Map<String, Object>) tenants.get(tenantKey);
+ if (!t.equals(tenant.get("type"))) {
+ continue;
+ }
+ Map<String, Object> locationType = (Map<String, Object>) locationTypes.get(t);
+ Map<String, Object> dockerDeployments = (Map<String, Object>) locationType.get("docker-deployments");
+ if (dockerDeployments == null) {
+ continue;
+ }
+ for (String dockerDeploymentKey : dockerDeployments.keySet()) {
+ Map<String, Object> dockerDeployment = (Map<String, Object>) dockerDeployments.get(dockerDeploymentKey);
+ Map<String, Object> dockerType = (Map<String, Object>) dockerTypes.get(dockerDeployment.get("docker-type"));
// if (dockerType.containsKey("error")) continue;
// System.err.println (" XXx:" + t + " " + vmDeploymentKey + " " + vmType.keySet()+ " " + container.keySet());
- LinkedHashMap<String,Object> s1 = new LinkedHashMap<String,Object>();
- s1.put("docker-type", dockerDeployment.get("docker-type"));
- s1.put("release", dockerDeployment.get("release"));
- s1.put("milestone", dockerDeployment.get("milestone"));
- s1.put("use-controller", true);
- s1.put("dcae-service", dockerDeploymentKey);
- s1.put("dcae-service-instance", tenantKey);
- String container = (String) dockerDeployment.get("container");
+ LinkedHashMap<String, Object> s1 = new LinkedHashMap<String, Object>();
+ s1.put("docker-type", dockerDeployment.get("docker-type"));
+ s1.put("release", dockerDeployment.get("release"));
+ s1.put("milestone", dockerDeployment.get("milestone"));
+ s1.put("use-controller", true);
+ s1.put("dcae-service", dockerDeploymentKey);
+ s1.put("dcae-service-instance", tenantKey);
+ String container = (String) dockerDeployment.get("container");
// container = container.replace("${location-name}", tenantKey);
- s1.put("dcae-container", container);
- s1.put("location-type", t);
- s.put(dockerDeploymentKey, s1);
- }
- }
- }
- return s;
- }
+ s1.put("dcae-container", container);
+ s1.put("location-type", t);
+ s.put(dockerDeploymentKey, s1);
+ }
+ }
+ }
+ return s;
+ }
+
+ private Map<String, Object> containers() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ private Object get(Map<String, Object> m, String k1, String k2, Object def) {
+ Object o = m.get(k1);
+ if (o instanceof Map<?, ?>) {
+ @SuppressWarnings("unchecked")
+ Map<String, Object> m1 = (Map<String, Object>) o;
+ return get(m1, k2, def);
+ }
+ return def;
+ }
+
+ private Object get(Map<String, Object> m, String k1, Object def) {
+ Object o = m.get(k1);
+ return o == null ? def : o;
+ }
+
+ static LinkedHashMap<String, String> env2char = new LinkedHashMap<String, String>();
- private Map<String, Object> containers() {
- // TODO Auto-generated method stub
- return null;
- }
+ static {
+ env2char.put("DEV", "zldc");
+ env2char.put("FTL", "zldc");
+ env2char.put("FTL2", "zldc");
+ env2char.put("IST", "zltc");
+ env2char.put("ISTFTL", "zltc");
+ env2char.put("ETE", "zlsc");
+ env2char.put("PROD", "zlpc");
+ }
- private Object get(Map<String, Object> m, String k1, String k2, Object def) {
- Object o = m.get(k1);
- if (o instanceof Map<?, ?>) {
- @SuppressWarnings("unchecked")
- Map<String, Object> m1 = (Map<String, Object>) o;
- return get(m1,k2,def);
- }
- return def;
- }
- private Object get(Map<String, Object> m, String k1, Object def) {
- Object o = m.get(k1);
- return o == null ? def : o;
- }
+ private String vmname(Map<String, Object> tenant, Map<String, Object> vmType, int i) {
+ String env1 = (String) tenant.get("environment-type");
+ if (env1 == null) {
+ env1 = env;
+ }
+ String s = env2char.get(env1);
+ if (s == null) {
+ s = env2char.get("DEV");
+ }
+ return s + tenant.get("name-short") + vmType.get("short-name") + String.format("%02d", i);
+ }
- static LinkedHashMap<String,String> env2char = new LinkedHashMap<String,String>();
-
- static {
- env2char.put("DEV", "zldc");
- env2char.put("FTL", "zldc");
- env2char.put("FTL2", "zldc");
- env2char.put("IST", "zltc");
- env2char.put("ISTFTL", "zltc");
- env2char.put("ETE", "zlsc");
- env2char.put("PROD", "zlpc");
- }
-
-
- private String vmname(Map<String, Object> tenant, Map<String, Object> vmType, int i) {
- String env1 = (String) tenant.get("environment-type");
- if (env1 == null) env1 = env;
- String s = env2char.get(env1);
- if (s == null) s = env2char.get("DEV");
- return s + tenant.get("name-short") + vmType.get("short-name") + String.format("%02d", i);
- }
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public Map types(String dType) {
+ LinkedHashMap<String, Object> s = new LinkedHashMap<String, Object>();
+ Map<String, Object> locationTypes = locationTypes();
+ for (String locationType : locationTypes.keySet()) {
+ Map<String, Object> o1 = (Map<String, Object>) locationTypes.get(locationType);
+ Map<String, Object> o2 = (Map<String, Object>) o1.get(dType + "-deployments");
+ if (o2 == null) {
+ continue;
+ }
+ for (String type : o2.keySet()) {
+ Map<String, Object> o3 = (Map<String, Object>) o2.get(type);
+ if (o3.containsKey(dType + "-type")) {
+ type = (String) o3.get(dType + "-type");
+ }
+ if (s.containsKey(type)) {
+ continue;
+ }
+ String path = release + "/" + dType + "-templates/" + type + ".yaml";
+ s.put(type, file2object(path));
+ }
+ }
+ return s;
+ }
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public Map types(String dType) {
- LinkedHashMap<String,Object> s = new LinkedHashMap<String,Object>();
- Map<String,Object> locationTypes = locationTypes();
- for (String locationType : locationTypes.keySet()) {
- Map<String,Object> o1 = (Map<String, Object>) locationTypes.get(locationType);
- Map<String,Object> o2 = (Map<String, Object>) o1.get(dType + "-deployments");
- if (o2 == null) continue;
- for (String type : o2.keySet()) {
- Map<String,Object> o3 = (Map<String, Object>) o2.get(type);
- if (o3.containsKey(dType + "-type"))
- type = (String) o3.get(dType + "-type");
- if (s.containsKey(type)) continue;
- String path = release + "/" + dType + "-templates/" + type + ".yaml";
- s.put(type,file2object(path));
- }
- }
- return s;
- }
+ protected static Object file2object(String path) {
+ return file2object(path, true);
+ }
- protected static Object file2object(String path) {
- return file2object(path, true);
- }
- protected static Object file2object(String path, boolean required) {
+ protected static Object file2object(String path, boolean required) {
// System.err.println (root + "/" + path);
- try {
- if (path.endsWith(".json")) {
+ try {
+ if (path.endsWith(".json")) {
// System.err.println (root + "/" + path);
- return json2object(JsonUtils.file2json(root + "/" + path));
- }
- else {
- Yaml yaml = new Yaml();
- String s = new String(Files.readAllBytes(Paths.get(root + "/" + path)), StandardCharsets.UTF_8);
- Object o = yaml.load(s);
- if (o != null) return o;
- }
- } catch (org.yaml.snakeyaml.parser.ParserException e) {
- System.err.println("YAML exception: " + path + " " + e);
- System.exit(2);
- } catch (Exception e) {
- System.err.println("exception: " + path + " " + e.getClass());
- if (required)
- System.err.println("exception: " + path + " " + e);
- else {
+ return json2object(JsonUtils.file2json(root + "/" + path));
+ } else {
+ Yaml yaml = new Yaml();
+ String s = new String(Files.readAllBytes(Paths.get(root + "/" + path)), StandardCharsets.UTF_8);
+ Object o = yaml.load(s);
+ if (o != null) {
+ return o;
+ }
+ }
+ } catch (org.yaml.snakeyaml.parser.ParserException e) {
+ System.err.println("YAML exception: " + path + " " + e);
+ System.exit(2);
+ } catch (Exception e) {
+ System.err.println("exception: " + path + " " + e.getClass());
+ if (required) {
+ System.err.println("exception: " + path + " " + e);
+ } else {
// System.err.println("exception: " + path + " " + e);
- return null;
- }
- }
- HashMap<String, String> m = new HashMap<String, String>();
- m.put("error", "No information about: " + path);
- return m;
- }
+ return null;
+ }
+ }
+ HashMap<String, String> m = new HashMap<String, String>();
+ m.put("error", "No information about: " + path);
+ return m;
+ }
- private static String object2yaml(Object object, List<String> l) {
- DumperOptions options = new DumperOptions();
- options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
- options.setSplitLines(true);
- options.setWidth(100000);
- Yaml y = new Yaml(options);
- Object o = object2json(object);
- if (o instanceof JSONArray) {
- JSONObject j = new JSONObject();
- j.put("ARRAY", object);
- o = j;
- }
- JSONObject json = (JSONObject) o;
- if (l != null) {
- for (String s : l) {
- if (json.has(s))
- json.remove(s);
- }
- }
- // the replace is due to JSONObject changes "</" to "<\/"
- Object data = y.load(json.toString().replace("<\\/", "</"));
- return y.dump(data);
- }
+ private static String object2yaml(Object object, List<String> l) {
+ DumperOptions options = new DumperOptions();
+ options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
+ options.setSplitLines(true);
+ options.setWidth(100000);
+ Yaml y = new Yaml(options);
+ Object o = object2json(object);
+ if (o instanceof JSONArray) {
+ JSONObject j = new JSONObject();
+ j.put("ARRAY", object);
+ o = j;
+ }
+ JSONObject json = (JSONObject) o;
+ if (l != null) {
+ for (String s : l) {
+ if (json.has(s)) {
+ json.remove(s);
+ }
+ }
+ }
+ // the replace is due to JSONObject changes "</" to "<\/"
+ Object data = y.load(json.toString().replace("<\\/", "</"));
+ return y.dump(data);
+ }
- public static void main(String[] args) {
- DocUtils d = new DocUtils("1607", "ISTFLT",null,null);
+ public static void main(String[] args) {
+ DocUtils d = new DocUtils("1607", "ISTFLT", null, null);
// System.err.println(object2yaml(d.tenants().get("local-willows"),null));
// System.err.println(object2yaml(d.types("vm"),null));
// System.err.println(object2yaml(d.types("docker"),null));
// System.err.println(object2yaml(d.types("cdap"),null));
// System.err.println(object2yaml(d.vms(),null));
- System.err.println(object2yaml(d.dockers(),null));
- }
+ System.err.println(object2yaml(d.dockers(), null));
+ }
}
diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/servers/controller/inventory/DcaeDcaeInventoryTest.java b/dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/servers/controller/inventory/DcaeDcaeInventoryTest.java
index 0ad21dd..5be2c61 100644
--- a/dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/servers/controller/inventory/DcaeDcaeInventoryTest.java
+++ b/dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/servers/controller/inventory/DcaeDcaeInventoryTest.java
@@ -5,19 +5,17 @@ import org.openecomp.ncomp.sirius.manager.ISiriusServer;
import org.openecomp.ncomp.sirius.manager.ManagementServer;
public class DcaeDcaeInventoryTest implements ISiriusServer {
+ private ManagementServer server = new ManagementServer();
- public static void main(String[] args) {
- DcaeDcaeInventoryTest server = new DcaeDcaeInventoryTest();
- DcaeInventoryFactory f = new DcaeInventoryFactory(server);
- DcaeInventory inv = f.createDcaeInventory();
- inv.poll();
- }
-
- private ManagementServer server = new ManagementServer();
-
- @Override
- public ManagementServer getServer() {
- return server;
- }
+ public static void main(String[] args) {
+ DcaeDcaeInventoryTest server = new DcaeDcaeInventoryTest();
+ DcaeInventoryFactory f = new DcaeInventoryFactory(server);
+ DcaeInventory inv = f.createDcaeInventory();
+ inv.poll();
+ }
+ @Override
+ public ManagementServer getServer() {
+ return server;
+ }
}
diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerCluster.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerCluster.java
index 893d909..d7b96a2 100644
--- a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerCluster.java
+++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerCluster.java
@@ -18,132 +18,108 @@
* limitations under the License.
* ============LICENSE_END============================================
*/
-
+
// Autogenerated
// Do not edit. No need to extend this class.
package org.openecomp.dcae.controller.platform.servers.controller;
-
-
-
-
-import java.io.InputStream;
-
-import org.openecomp.ncomp.sirius.manager.IRequestHandler;
-import org.openecomp.ncomp.sirius.manager.ISwaggerHandler;
+import org.apache.log4j.Logger;
+import org.openecomp.dcae.controller.platform.controller.impl.ControllerClusterImpl;
+import org.openecomp.dcae.controller.platform.servers.controller.logging.ControllerClusterMessageEnum;
+import org.openecomp.dcae.controller.platform.servers.controller.logging.ControllerClusterOperationEnum;
+import org.openecomp.logger.EcompException;
+import org.openecomp.logger.StatusCodeEnum;
+import org.openecomp.ncomp.component.ApiRequestStatus;
import org.openecomp.ncomp.sirius.manager.ISiriusPlugin;
-import org.openecomp.ncomp.sirius.manager.ISiriusServer;
import org.openecomp.ncomp.sirius.manager.ISiriusProvider;
+import org.openecomp.ncomp.sirius.manager.ISiriusServer;
import org.openecomp.ncomp.sirius.manager.ManagementServer;
-import org.openecomp.ncomp.sirius.manager.SwaggerUtils;
-import org.openecomp.ncomp.sirius.function.FunctionUtils;
-import org.openecomp.ncomp.component.ApiRequestStatus;
-
-import org.apache.log4j.Logger;
-
import org.openecomp.ncomp.sirius.manager.logging.NcompLogger;
-import org.openecomp.logger.StatusCodeEnum;
-import org.openecomp.logger.EcompException;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.json.JSONObject;
import java.util.Date;
-import org.openecomp.dcae.controller.platform.servers.controller.logging.ControllerClusterOperationEnum;
-import org.openecomp.dcae.controller.platform.servers.controller.logging.ControllerClusterMessageEnum;
-
-
-
-
-import org.openecomp.dcae.controller.platform.controller.impl.ControllerClusterImpl;
-
-
-
public class DcaeControllerCluster extends ControllerClusterImpl implements ISiriusProvider, ISiriusPlugin {
- public static final Logger logger = Logger.getLogger(DcaeControllerCluster.class);
- static final NcompLogger ecomplogger = NcompLogger.getNcompLogger();
- public DcaeControllerClusterProvider controller;
- ISiriusServer server;
-
- public DcaeControllerCluster(ISiriusServer server) {
- this.server = server;
- this.controller = new DcaeControllerClusterProvider(server,this);
- }
-
- public void pushData(java.lang.String serverName, java.lang.String dataName) {
-
- long duration_ = 0;
- if (server != null)
- server.getServer().recordApi(null, this, "pushData", ApiRequestStatus.START, duration_,serverName,dataName);
- Date now_ = new Date();
- ecomplogger.recordAuditEventStartIfNeeded(ControllerClusterOperationEnum.ControllerCluster_pushData,server,this);
- ecomplogger.recordMetricEventStart(ControllerClusterOperationEnum.ControllerCluster_pushData,"self:" + ManagementServer.object2ref(this));
- try {
- controller.pushData(serverName,dataName);
- }
- catch (Exception e) {
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "pushData", ApiRequestStatus.ERROR, duration_,serverName,dataName);
- System.err.println("ERROR: " + e);
- ecomplogger.warn(ControllerClusterMessageEnum.REQUEST_FAILED_pushData, e.toString());
- EcompException e1 = EcompException.create(ControllerClusterMessageEnum.REQUEST_FAILED_pushData,e,e.getMessage());
- ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerClusterMessageEnum.REQUEST_FAILED_pushData, e.getMessage());
- throw e1;
- }
- ecomplogger.recordMetricEventEnd();
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "pushData", ApiRequestStatus.OKAY, duration_,serverName,dataName);
-
- }
-
- public void receiveData(java.lang.String serverName, java.lang.String dataName, java.util.Date time, java.lang.String content) {
-
- long duration_ = 0;
- if (server != null)
- server.getServer().recordApi(null, this, "receiveData", ApiRequestStatus.START, duration_,serverName,dataName,time,content);
- Date now_ = new Date();
- ecomplogger.recordAuditEventStartIfNeeded(ControllerClusterOperationEnum.ControllerCluster_receiveData,server,this);
- ecomplogger.recordMetricEventStart(ControllerClusterOperationEnum.ControllerCluster_receiveData,"self:" + ManagementServer.object2ref(this));
- try {
- controller.receiveData(serverName,dataName,time,content);
- }
- catch (Exception e) {
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "receiveData", ApiRequestStatus.ERROR, duration_,serverName,dataName,time,content);
- System.err.println("ERROR: " + e);
- ecomplogger.warn(ControllerClusterMessageEnum.REQUEST_FAILED_receiveData, e.toString());
- EcompException e1 = EcompException.create(ControllerClusterMessageEnum.REQUEST_FAILED_receiveData,e,e.getMessage());
- ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerClusterMessageEnum.REQUEST_FAILED_receiveData, e.getMessage());
- throw e1;
- }
- ecomplogger.recordMetricEventEnd();
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "receiveData", ApiRequestStatus.OKAY, duration_,serverName,dataName,time,content);
-
- }
-
-
-
-
-
-
-
-
- @Override
- public void start() {
- controller.start();
- }
-
- public static void ecoreSetup() {
- DcaeControllerClusterProvider.ecoreSetup();
- }
- public DcaeControllerClusterProvider getSiriusProvider() {
- return controller;
- }
+ public static final Logger logger = Logger.getLogger(DcaeControllerCluster.class);
+ static final NcompLogger ecomplogger = NcompLogger.getNcompLogger();
+ public DcaeControllerClusterProvider controller;
+ ISiriusServer server;
+
+ public DcaeControllerCluster(ISiriusServer server) {
+ this.server = server;
+ this.controller = new DcaeControllerClusterProvider(server, this);
+ }
+
+ public void pushData(java.lang.String serverName, java.lang.String dataName) {
+
+ long duration_ = 0;
+ if (server != null) {
+ server.getServer().recordApi(null, this, "pushData", ApiRequestStatus.START, duration_, serverName, dataName);
+ }
+ Date now_ = new Date();
+ ecomplogger.recordAuditEventStartIfNeeded(ControllerClusterOperationEnum.ControllerCluster_pushData, server, this);
+ ecomplogger.recordMetricEventStart(ControllerClusterOperationEnum.ControllerCluster_pushData, "self:" + ManagementServer.object2ref(this));
+ try {
+ controller.pushData(serverName, dataName);
+ } catch (Exception e) {
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "pushData", ApiRequestStatus.ERROR, duration_, serverName, dataName);
+ }
+ System.err.println("ERROR: " + e);
+ ecomplogger.warn(ControllerClusterMessageEnum.REQUEST_FAILED_pushData, e.toString());
+ EcompException e1 = EcompException.create(ControllerClusterMessageEnum.REQUEST_FAILED_pushData, e, e.getMessage());
+ ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerClusterMessageEnum.REQUEST_FAILED_pushData, e.getMessage());
+ throw e1;
+ }
+ ecomplogger.recordMetricEventEnd();
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "pushData", ApiRequestStatus.OKAY, duration_, serverName, dataName);
+ }
+
+ }
+
+ public void receiveData(java.lang.String serverName, java.lang.String dataName, java.util.Date time, java.lang.String content) {
+
+ long duration_ = 0;
+ if (server != null) {
+ server.getServer().recordApi(null, this, "receiveData", ApiRequestStatus.START, duration_, serverName, dataName, time, content);
+ }
+ Date now_ = new Date();
+ ecomplogger.recordAuditEventStartIfNeeded(ControllerClusterOperationEnum.ControllerCluster_receiveData, server, this);
+ ecomplogger.recordMetricEventStart(ControllerClusterOperationEnum.ControllerCluster_receiveData, "self:" + ManagementServer.object2ref(this));
+ try {
+ controller.receiveData(serverName, dataName, time, content);
+ } catch (Exception e) {
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "receiveData", ApiRequestStatus.ERROR, duration_, serverName, dataName, time, content);
+ }
+ System.err.println("ERROR: " + e);
+ ecomplogger.warn(ControllerClusterMessageEnum.REQUEST_FAILED_receiveData, e.toString());
+ EcompException e1 = EcompException.create(ControllerClusterMessageEnum.REQUEST_FAILED_receiveData, e, e.getMessage());
+ ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerClusterMessageEnum.REQUEST_FAILED_receiveData, e.getMessage());
+ throw e1;
+ }
+ ecomplogger.recordMetricEventEnd();
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "receiveData", ApiRequestStatus.OKAY, duration_, serverName, dataName, time, content);
+ }
+
+ }
+
+ @Override
+ public void start() {
+ controller.start();
+ }
+
+ public static void ecoreSetup() {
+ DcaeControllerClusterProvider.ecoreSetup();
+ }
+
+ @Override
+ public DcaeControllerClusterProvider getSiriusProvider() {
+ return controller;
+ }
}
diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerVirtualMachineService.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerVirtualMachineService.java
index a44f9bd..d088a34 100644
--- a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerVirtualMachineService.java
+++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerVirtualMachineService.java
@@ -18,412 +18,410 @@
* limitations under the License.
* ============LICENSE_END============================================
*/
-
+
// Autogenerated
// Do not edit. No need to extend this class.
package org.openecomp.dcae.controller.platform.servers.controller;
-
-
-
-
-import java.io.InputStream;
-
-import org.openecomp.ncomp.sirius.manager.IRequestHandler;
-import org.openecomp.ncomp.sirius.manager.ISwaggerHandler;
+import org.apache.log4j.Logger;
+import org.eclipse.emf.ecore.EObject;
+import org.openecomp.dcae.controller.platform.controller.impl.ControllerVirtualMachineServiceImpl;
+import org.openecomp.dcae.controller.platform.servers.controller.logging.ControllerVirtualMachineServiceMessageEnum;
+import org.openecomp.dcae.controller.platform.servers.controller.logging.ControllerVirtualMachineServiceOperationEnum;
+import org.openecomp.logger.EcompException;
+import org.openecomp.logger.StatusCodeEnum;
+import org.openecomp.ncomp.component.ApiRequestStatus;
import org.openecomp.ncomp.sirius.manager.ISiriusPlugin;
-import org.openecomp.ncomp.sirius.manager.ISiriusServer;
import org.openecomp.ncomp.sirius.manager.ISiriusProvider;
+import org.openecomp.ncomp.sirius.manager.ISiriusServer;
import org.openecomp.ncomp.sirius.manager.ManagementServer;
-import org.openecomp.ncomp.sirius.manager.SwaggerUtils;
-import org.openecomp.ncomp.sirius.function.FunctionUtils;
-import org.openecomp.ncomp.component.ApiRequestStatus;
-
-import org.apache.log4j.Logger;
-
import org.openecomp.ncomp.sirius.manager.logging.NcompLogger;
-import org.openecomp.logger.StatusCodeEnum;
-import org.openecomp.logger.EcompException;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.json.JSONObject;
import java.util.Date;
-import org.openecomp.dcae.controller.platform.servers.controller.logging.ControllerVirtualMachineServiceOperationEnum;
-import org.openecomp.dcae.controller.platform.servers.controller.logging.ControllerVirtualMachineServiceMessageEnum;
-
-
-
-
-import org.openecomp.dcae.controller.platform.controller.impl.ControllerVirtualMachineServiceImpl;
-
-
-
public class DcaeControllerVirtualMachineService extends ControllerVirtualMachineServiceImpl implements ISiriusProvider, ISiriusPlugin {
- public static final Logger logger = Logger.getLogger(DcaeControllerVirtualMachineService.class);
- static final NcompLogger ecomplogger = NcompLogger.getNcompLogger();
- public DcaeControllerVirtualMachineServiceProvider controller;
- ISiriusServer server;
-
- public DcaeControllerVirtualMachineService(ISiriusServer server) {
- this.server = server;
- this.controller = new DcaeControllerVirtualMachineServiceProvider(server,this);
- }
-
- public void deploy(java.lang.String instanceName, java.lang.String containerPath) {
-
- long duration_ = 0;
- if (server != null)
- server.getServer().recordApi(null, this, "deploy", ApiRequestStatus.START, duration_,instanceName,containerPath);
- Date now_ = new Date();
- ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_deploy,server,this);
- ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_deploy,"self:" + ManagementServer.object2ref(this));
- try {
- controller.deploy(instanceName,containerPath);
- }
- catch (Exception e) {
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "deploy", ApiRequestStatus.ERROR, duration_,instanceName,containerPath);
- System.err.println("ERROR: " + e);
- ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_deploy, e.toString());
- EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_deploy,e,e.getMessage());
- ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_deploy, e.getMessage());
- throw e1;
- }
- ecomplogger.recordMetricEventEnd();
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "deploy", ApiRequestStatus.OKAY, duration_,instanceName,containerPath);
-
- }
-
- public void undeploy(java.lang.String instanceName) {
-
- long duration_ = 0;
- if (server != null)
- server.getServer().recordApi(null, this, "undeploy", ApiRequestStatus.START, duration_,instanceName);
- Date now_ = new Date();
- ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_undeploy,server,this);
- ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_undeploy,"self:" + ManagementServer.object2ref(this));
- try {
- controller.undeploy(instanceName);
- }
- catch (Exception e) {
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "undeploy", ApiRequestStatus.ERROR, duration_,instanceName);
- System.err.println("ERROR: " + e);
- ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_undeploy, e.toString());
- EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_undeploy,e,e.getMessage());
- ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_undeploy, e.getMessage());
- throw e1;
- }
- ecomplogger.recordMetricEventEnd();
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "undeploy", ApiRequestStatus.OKAY, duration_,instanceName);
-
- }
-
- public org.openecomp.dcae.controller.core.service.HealthTestResponse test(java.lang.String instanceName) {
- org.openecomp.dcae.controller.core.service.HealthTestResponse res = null;
- long duration_ = 0;
- if (server != null)
- server.getServer().recordApi(null, this, "test", ApiRequestStatus.START, duration_,instanceName);
- Date now_ = new Date();
- ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_test,server,this);
- ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_test,"self:" + ManagementServer.object2ref(this));
- try {
- res = controller.test(instanceName);
- }
- catch (Exception e) {
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "test", ApiRequestStatus.ERROR, duration_,instanceName);
- System.err.println("ERROR: " + e);
- ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_test, e.toString());
- EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_test,e,e.getMessage());
- ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_test, e.getMessage());
- throw e1;
- }
- ecomplogger.recordMetricEventEnd();
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "test", ApiRequestStatus.OKAY, duration_,instanceName);
- return res;
- }
-
- public void suspend(java.lang.String instanceName) {
-
- long duration_ = 0;
- if (server != null)
- server.getServer().recordApi(null, this, "suspend", ApiRequestStatus.START, duration_,instanceName);
- Date now_ = new Date();
- ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_suspend,server,this);
- ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_suspend,"self:" + ManagementServer.object2ref(this));
- try {
- controller.suspend(instanceName);
- }
- catch (Exception e) {
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "suspend", ApiRequestStatus.ERROR, duration_,instanceName);
- System.err.println("ERROR: " + e);
- ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_suspend, e.toString());
- EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_suspend,e,e.getMessage());
- ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_suspend, e.getMessage());
- throw e1;
- }
- ecomplogger.recordMetricEventEnd();
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "suspend", ApiRequestStatus.OKAY, duration_,instanceName);
-
- }
-
- public void resume(java.lang.String instanceName) {
-
- long duration_ = 0;
- if (server != null)
- server.getServer().recordApi(null, this, "resume", ApiRequestStatus.START, duration_,instanceName);
- Date now_ = new Date();
- ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_resume,server,this);
- ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_resume,"self:" + ManagementServer.object2ref(this));
- try {
- controller.resume(instanceName);
- }
- catch (Exception e) {
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "resume", ApiRequestStatus.ERROR, duration_,instanceName);
- System.err.println("ERROR: " + e);
- ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_resume, e.toString());
- EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_resume,e,e.getMessage());
- ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_resume, e.getMessage());
- throw e1;
- }
- ecomplogger.recordMetricEventEnd();
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "resume", ApiRequestStatus.OKAY, duration_,instanceName);
-
- }
-
- public void pushManagerConfiguration(java.lang.String instanceName) {
-
- long duration_ = 0;
- if (server != null)
- server.getServer().recordApi(null, this, "pushManagerConfiguration", ApiRequestStatus.START, duration_,instanceName);
- Date now_ = new Date();
- ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_pushManagerConfiguration,server,this);
- ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_pushManagerConfiguration,"self:" + ManagementServer.object2ref(this));
- try {
- controller.pushManagerConfiguration(instanceName);
- }
- catch (Exception e) {
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "pushManagerConfiguration", ApiRequestStatus.ERROR, duration_,instanceName);
- System.err.println("ERROR: " + e);
- ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_pushManagerConfiguration, e.toString());
- EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_pushManagerConfiguration,e,e.getMessage());
- ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_pushManagerConfiguration, e.getMessage());
- throw e1;
- }
- ecomplogger.recordMetricEventEnd();
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "pushManagerConfiguration", ApiRequestStatus.OKAY, duration_,instanceName);
-
- }
-
- public void pollManagerConfiguration(java.lang.String instanceName) {
-
- long duration_ = 0;
- if (server != null)
- server.getServer().recordApi(null, this, "pollManagerConfiguration", ApiRequestStatus.START, duration_,instanceName);
- Date now_ = new Date();
- ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_pollManagerConfiguration,server,this);
- ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_pollManagerConfiguration,"self:" + ManagementServer.object2ref(this));
- try {
- controller.pollManagerConfiguration(instanceName);
- }
- catch (Exception e) {
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "pollManagerConfiguration", ApiRequestStatus.ERROR, duration_,instanceName);
- System.err.println("ERROR: " + e);
- ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_pollManagerConfiguration, e.toString());
- EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_pollManagerConfiguration,e,e.getMessage());
- ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_pollManagerConfiguration, e.getMessage());
- throw e1;
- }
- ecomplogger.recordMetricEventEnd();
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "pollManagerConfiguration", ApiRequestStatus.OKAY, duration_,instanceName);
-
- }
-
- public org.eclipse.emf.ecore.EObject managerConfiguration(java.lang.String instanceName) {
- org.eclipse.emf.ecore.EObject res = null;
- long duration_ = 0;
- if (server != null)
- server.getServer().recordApi(null, this, "managerConfiguration", ApiRequestStatus.START, duration_,instanceName);
- Date now_ = new Date();
- ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_managerConfiguration,server,this);
- ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_managerConfiguration,"self:" + ManagementServer.object2ref(this));
- try {
- res = controller.managerConfiguration(instanceName);
- }
- catch (Exception e) {
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "managerConfiguration", ApiRequestStatus.ERROR, duration_,instanceName);
- System.err.println("ERROR: " + e);
- ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_managerConfiguration, e.toString());
- EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_managerConfiguration,e,e.getMessage());
- ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_managerConfiguration, e.getMessage());
- throw e1;
- }
- ecomplogger.recordMetricEventEnd();
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "managerConfiguration", ApiRequestStatus.OKAY, duration_,instanceName);
- return res;
- }
-
- public org.json.JSONObject managerOperation(java.lang.String instanceName, java.lang.String operation, org.json.JSONObject parameters) {
- org.json.JSONObject res = null;
- long duration_ = 0;
- if (server != null)
- server.getServer().recordApi(null, this, "managerOperation", ApiRequestStatus.START, duration_,instanceName,operation,parameters);
- Date now_ = new Date();
- ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_managerOperation,server,this);
- ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_managerOperation,"self:" + ManagementServer.object2ref(this));
- try {
- res = controller.managerOperation(instanceName,operation,parameters);
- }
- catch (Exception e) {
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "managerOperation", ApiRequestStatus.ERROR, duration_,instanceName,operation,parameters);
- System.err.println("ERROR: " + e);
- ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_managerOperation, e.toString());
- EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_managerOperation,e,e.getMessage());
- ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_managerOperation, e.getMessage());
- throw e1;
- }
- ecomplogger.recordMetricEventEnd();
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "managerOperation", ApiRequestStatus.OKAY, duration_,instanceName,operation,parameters);
- return res;
- }
-
- public void updateConfigurationFromPolicy(java.lang.String instanceName) {
-
- long duration_ = 0;
- if (server != null)
- server.getServer().recordApi(null, this, "updateConfigurationFromPolicy", ApiRequestStatus.START, duration_,instanceName);
- Date now_ = new Date();
- ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_updateConfigurationFromPolicy,server,this);
- ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_updateConfigurationFromPolicy,"self:" + ManagementServer.object2ref(this));
- try {
- controller.updateConfigurationFromPolicy(instanceName);
- }
- catch (Exception e) {
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "updateConfigurationFromPolicy", ApiRequestStatus.ERROR, duration_,instanceName);
- System.err.println("ERROR: " + e);
- ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_updateConfigurationFromPolicy, e.toString());
- EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_updateConfigurationFromPolicy,e,e.getMessage());
- ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_updateConfigurationFromPolicy, e.getMessage());
- throw e1;
- }
- ecomplogger.recordMetricEventEnd();
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "updateConfigurationFromPolicy", ApiRequestStatus.OKAY, duration_,instanceName);
-
- }
-
- public void runHealthTests() {
-
- long duration_ = 0;
- if (server != null)
- server.getServer().recordApi(null, this, "runHealthTests", ApiRequestStatus.START, duration_);
- Date now_ = new Date();
- ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_runHealthTests,server,this);
- ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_runHealthTests,"self:" + ManagementServer.object2ref(this));
- try {
- controller.runHealthTests();
- }
- catch (Exception e) {
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "runHealthTests", ApiRequestStatus.ERROR, duration_);
- System.err.println("ERROR: " + e);
- ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_runHealthTests, e.toString());
- EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_runHealthTests,e,e.getMessage());
- ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_runHealthTests, e.getMessage());
- throw e1;
- }
- ecomplogger.recordMetricEventEnd();
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "runHealthTests", ApiRequestStatus.OKAY, duration_);
-
- }
-
- public void updateDeploymentStatus() {
-
- long duration_ = 0;
- if (server != null)
- server.getServer().recordApi(null, this, "updateDeploymentStatus", ApiRequestStatus.START, duration_);
- Date now_ = new Date();
- ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_updateDeploymentStatus,server,this);
- ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_updateDeploymentStatus,"self:" + ManagementServer.object2ref(this));
- try {
- controller.updateDeploymentStatus();
- }
- catch (Exception e) {
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "updateDeploymentStatus", ApiRequestStatus.ERROR, duration_);
- System.err.println("ERROR: " + e);
- ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_updateDeploymentStatus, e.toString());
- EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_updateDeploymentStatus,e,e.getMessage());
- ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_updateDeploymentStatus, e.getMessage());
- throw e1;
- }
- ecomplogger.recordMetricEventEnd();
- duration_ = new Date().getTime()-now_.getTime();
- if (server != null)
- server.getServer().recordApi(null, this, "updateDeploymentStatus", ApiRequestStatus.OKAY, duration_);
-
- }
-
-
-
-
-
-
-
-
- @Override
- public void start() {
- controller.start();
- }
-
- public static void ecoreSetup() {
- DcaeControllerVirtualMachineServiceProvider.ecoreSetup();
- }
- public DcaeControllerVirtualMachineServiceProvider getSiriusProvider() {
- return controller;
- }
+ public static final Logger logger = Logger.getLogger(DcaeControllerVirtualMachineService.class);
+ static final NcompLogger ecomplogger = NcompLogger.getNcompLogger();
+ public DcaeControllerVirtualMachineServiceProvider controller;
+ ISiriusServer server;
+
+ public DcaeControllerVirtualMachineService(ISiriusServer server) {
+ this.server = server;
+ this.controller = new DcaeControllerVirtualMachineServiceProvider(server, this);
+ }
+
+ public void deploy(java.lang.String instanceName, java.lang.String containerPath) {
+
+ long duration_ = 0;
+ if (server != null) {
+ server.getServer().recordApi(null, this, "deploy", ApiRequestStatus.START, duration_, instanceName, containerPath);
+ }
+ Date now_ = new Date();
+ ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_deploy, server, this);
+ ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_deploy, "self:" + ManagementServer.object2ref(this));
+ try {
+ controller.deploy(instanceName, containerPath);
+ } catch (Exception e) {
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "deploy", ApiRequestStatus.ERROR, duration_, instanceName, containerPath);
+ }
+ System.err.println("ERROR: " + e);
+ ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_deploy, e.toString());
+ EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_deploy, e, e.getMessage());
+ ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_deploy, e.getMessage());
+ throw e1;
+ }
+ ecomplogger.recordMetricEventEnd();
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "deploy", ApiRequestStatus.OKAY, duration_, instanceName, containerPath);
+ }
+
+ }
+
+ public void undeploy(java.lang.String instanceName) {
+
+ long duration_ = 0;
+ if (server != null) {
+ server.getServer().recordApi(null, this, "undeploy", ApiRequestStatus.START, duration_, instanceName);
+ }
+ Date now_ = new Date();
+ ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_undeploy, server, this);
+ ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_undeploy, "self:" + ManagementServer.object2ref(this));
+ try {
+ controller.undeploy(instanceName);
+ } catch (Exception e) {
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "undeploy", ApiRequestStatus.ERROR, duration_, instanceName);
+ }
+ System.err.println("ERROR: " + e);
+ ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_undeploy, e.toString());
+ EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_undeploy, e, e.getMessage());
+ ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_undeploy, e.getMessage());
+ throw e1;
+ }
+ ecomplogger.recordMetricEventEnd();
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "undeploy", ApiRequestStatus.OKAY, duration_, instanceName);
+ }
+
+ }
+
+ public org.openecomp.dcae.controller.core.service.HealthTestResponse test(java.lang.String instanceName) {
+ org.openecomp.dcae.controller.core.service.HealthTestResponse res = null;
+ long duration_ = 0;
+ if (server != null) {
+ server.getServer().recordApi(null, this, "test", ApiRequestStatus.START, duration_, instanceName);
+ }
+ Date now_ = new Date();
+ ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_test, server, this);
+ ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_test, "self:" + ManagementServer.object2ref(this));
+ try {
+ res = controller.test(instanceName);
+ } catch (Exception e) {
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "test", ApiRequestStatus.ERROR, duration_, instanceName);
+ }
+ System.err.println("ERROR: " + e);
+ ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_test, e.toString());
+ EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_test, e, e.getMessage());
+ ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_test, e.getMessage());
+ throw e1;
+ }
+ ecomplogger.recordMetricEventEnd();
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "test", ApiRequestStatus.OKAY, duration_, instanceName);
+ }
+ return res;
+ }
+
+ public void suspend(java.lang.String instanceName) {
+
+ long duration_ = 0;
+ if (server != null) {
+ server.getServer().recordApi(null, this, "suspend", ApiRequestStatus.START, duration_, instanceName);
+ }
+ Date now_ = new Date();
+ ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_suspend, server, this);
+ ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_suspend, "self:" + ManagementServer.object2ref(this));
+ try {
+ controller.suspend(instanceName);
+ } catch (Exception e) {
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "suspend", ApiRequestStatus.ERROR, duration_, instanceName);
+ }
+ System.err.println("ERROR: " + e);
+ ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_suspend, e.toString());
+ EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_suspend, e, e.getMessage());
+ ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_suspend, e.getMessage());
+ throw e1;
+ }
+ ecomplogger.recordMetricEventEnd();
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "suspend", ApiRequestStatus.OKAY, duration_, instanceName);
+ }
+
+ }
+
+ public void resume(java.lang.String instanceName) {
+
+ long duration_ = 0;
+ if (server != null) {
+ server.getServer().recordApi(null, this, "resume", ApiRequestStatus.START, duration_, instanceName);
+ }
+ Date now_ = new Date();
+ ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_resume, server, this);
+ ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_resume, "self:" + ManagementServer.object2ref(this));
+ try {
+ controller.resume(instanceName);
+ } catch (Exception e) {
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "resume", ApiRequestStatus.ERROR, duration_, instanceName);
+ }
+ System.err.println("ERROR: " + e);
+ ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_resume, e.toString());
+ EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_resume, e, e.getMessage());
+ ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_resume, e.getMessage());
+ throw e1;
+ }
+ ecomplogger.recordMetricEventEnd();
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "resume", ApiRequestStatus.OKAY, duration_, instanceName);
+ }
+
+ }
+
+ public void pushManagerConfiguration(java.lang.String instanceName) {
+
+ long duration_ = 0;
+ if (server != null) {
+ server.getServer().recordApi(null, this, "pushManagerConfiguration", ApiRequestStatus.START, duration_, instanceName);
+ }
+ Date now_ = new Date();
+ ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_pushManagerConfiguration, server, this);
+ ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_pushManagerConfiguration, "self:" + ManagementServer.object2ref(this));
+ try {
+ controller.pushManagerConfiguration(instanceName);
+ } catch (Exception e) {
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "pushManagerConfiguration", ApiRequestStatus.ERROR, duration_, instanceName);
+ }
+ System.err.println("ERROR: " + e);
+ ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_pushManagerConfiguration, e.toString());
+ EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_pushManagerConfiguration, e, e.getMessage());
+ ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_pushManagerConfiguration, e.getMessage());
+ throw e1;
+ }
+ ecomplogger.recordMetricEventEnd();
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "pushManagerConfiguration", ApiRequestStatus.OKAY, duration_, instanceName);
+ }
+
+ }
+
+ public void pollManagerConfiguration(java.lang.String instanceName) {
+
+ long duration_ = 0;
+ if (server != null) {
+ server.getServer().recordApi(null, this, "pollManagerConfiguration", ApiRequestStatus.START, duration_, instanceName);
+ }
+ Date now_ = new Date();
+ ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_pollManagerConfiguration, server, this);
+ ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_pollManagerConfiguration, "self:" + ManagementServer.object2ref(this));
+ try {
+ controller.pollManagerConfiguration(instanceName);
+ } catch (Exception e) {
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "pollManagerConfiguration", ApiRequestStatus.ERROR, duration_, instanceName);
+ }
+ System.err.println("ERROR: " + e);
+ ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_pollManagerConfiguration, e.toString());
+ EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_pollManagerConfiguration, e, e.getMessage());
+ ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_pollManagerConfiguration, e.getMessage());
+ throw e1;
+ }
+ ecomplogger.recordMetricEventEnd();
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "pollManagerConfiguration", ApiRequestStatus.OKAY, duration_, instanceName);
+ }
+
+ }
+
+ public org.eclipse.emf.ecore.EObject managerConfiguration(java.lang.String instanceName) {
+ org.eclipse.emf.ecore.EObject res = null;
+ long duration_ = 0;
+ if (server != null) {
+ server.getServer().recordApi(null, this, "managerConfiguration", ApiRequestStatus.START, duration_, instanceName);
+ }
+ Date now_ = new Date();
+ ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_managerConfiguration, server, this);
+ ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_managerConfiguration, "self:" + ManagementServer.object2ref(this));
+ try {
+ res = controller.managerConfiguration(instanceName);
+ } catch (Exception e) {
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "managerConfiguration", ApiRequestStatus.ERROR, duration_, instanceName);
+ }
+ System.err.println("ERROR: " + e);
+ ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_managerConfiguration, e.toString());
+ EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_managerConfiguration, e, e.getMessage());
+ ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_managerConfiguration, e.getMessage());
+ throw e1;
+ }
+ ecomplogger.recordMetricEventEnd();
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "managerConfiguration", ApiRequestStatus.OKAY, duration_, instanceName);
+ }
+ return res;
+ }
+
+ public org.json.JSONObject managerOperation(java.lang.String instanceName, java.lang.String operation, org.json.JSONObject parameters) {
+ org.json.JSONObject res = null;
+ long duration_ = 0;
+ if (server != null) {
+ server.getServer().recordApi(null, this, "managerOperation", ApiRequestStatus.START, duration_, instanceName, operation, parameters);
+ }
+ Date now_ = new Date();
+ ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_managerOperation, server, this);
+ ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_managerOperation, "self:" + ManagementServer.object2ref(this));
+ try {
+ res = controller.managerOperation(instanceName, operation, parameters);
+ } catch (Exception e) {
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "managerOperation", ApiRequestStatus.ERROR, duration_, instanceName, operation, parameters);
+ }
+ System.err.println("ERROR: " + e);
+ ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_managerOperation, e.toString());
+ EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_managerOperation, e, e.getMessage());
+ ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_managerOperation, e.getMessage());
+ throw e1;
+ }
+ ecomplogger.recordMetricEventEnd();
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "managerOperation", ApiRequestStatus.OKAY, duration_, instanceName, operation, parameters);
+ }
+ return res;
+ }
+
+ public void updateConfigurationFromPolicy(java.lang.String instanceName) {
+
+ long duration_ = 0;
+ if (server != null) {
+ server.getServer().recordApi(null, this, "updateConfigurationFromPolicy", ApiRequestStatus.START, duration_, instanceName);
+ }
+ Date now_ = new Date();
+ ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_updateConfigurationFromPolicy, server, this);
+ ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_updateConfigurationFromPolicy, "self:" + ManagementServer.object2ref(this));
+ try {
+ controller.updateConfigurationFromPolicy(instanceName);
+ } catch (Exception e) {
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "updateConfigurationFromPolicy", ApiRequestStatus.ERROR, duration_, instanceName);
+ }
+ System.err.println("ERROR: " + e);
+ ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_updateConfigurationFromPolicy, e.toString());
+ EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_updateConfigurationFromPolicy, e, e.getMessage());
+ ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_updateConfigurationFromPolicy, e.getMessage());
+ throw e1;
+ }
+ ecomplogger.recordMetricEventEnd();
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "updateConfigurationFromPolicy", ApiRequestStatus.OKAY, duration_, instanceName);
+ }
+
+ }
+
+ public void runHealthTests() {
+
+ long duration_ = 0;
+ if (server != null) {
+ server.getServer().recordApi(null, this, "runHealthTests", ApiRequestStatus.START, duration_);
+ }
+ Date now_ = new Date();
+ ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_runHealthTests, server, this);
+ ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_runHealthTests, "self:" + ManagementServer.object2ref(this));
+ try {
+ controller.runHealthTests();
+ } catch (Exception e) {
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "runHealthTests", ApiRequestStatus.ERROR, duration_);
+ }
+ System.err.println("ERROR: " + e);
+ ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_runHealthTests, e.toString());
+ EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_runHealthTests, e, e.getMessage());
+ ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_runHealthTests, e.getMessage());
+ throw e1;
+ }
+ ecomplogger.recordMetricEventEnd();
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "runHealthTests", ApiRequestStatus.OKAY, duration_);
+ }
+
+ }
+
+ public void updateDeploymentStatus() {
+
+ long duration_ = 0;
+ if (server != null) {
+ server.getServer().recordApi(null, this, "updateDeploymentStatus", ApiRequestStatus.START, duration_);
+ }
+ Date now_ = new Date();
+ ecomplogger.recordAuditEventStartIfNeeded(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_updateDeploymentStatus, server, this);
+ ecomplogger.recordMetricEventStart(ControllerVirtualMachineServiceOperationEnum.ControllerVirtualMachineService_updateDeploymentStatus, "self:" + ManagementServer.object2ref(this));
+ try {
+ controller.updateDeploymentStatus();
+ } catch (Exception e) {
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "updateDeploymentStatus", ApiRequestStatus.ERROR, duration_);
+ }
+ System.err.println("ERROR: " + e);
+ ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_updateDeploymentStatus, e.toString());
+ EcompException e1 = EcompException.create(ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_updateDeploymentStatus, e, e.getMessage());
+ ecomplogger.recordMetricEventEnd(StatusCodeEnum.ERROR, ControllerVirtualMachineServiceMessageEnum.REQUEST_FAILED_updateDeploymentStatus, e.getMessage());
+ throw e1;
+ }
+ ecomplogger.recordMetricEventEnd();
+ duration_ = new Date().getTime() - now_.getTime();
+ if (server != null) {
+ server.getServer().recordApi(null, this, "updateDeploymentStatus", ApiRequestStatus.OKAY, duration_);
+ }
+
+ }
+
+
+ @Override
+ public void start() {
+ controller.start();
+ }
+
+ public static void ecoreSetup() {
+ DcaeControllerVirtualMachineServiceProvider.ecoreSetup();
+ }
+
+ @Override
+ public DcaeControllerVirtualMachineServiceProvider getSiriusProvider() {
+ return controller;
+ }
}
diff --git a/dcae-controller-service-cdap/dcae-controller-service-cdap-cluster/dcae-controller-service-cdap-cluster-manager/src/main/java/org/openecomp/dcae/controller/service/cdap/cluster/servers/manager/DcaeCdapClusterManagerProvider.java b/dcae-controller-service-cdap/dcae-controller-service-cdap-cluster/dcae-controller-service-cdap-cluster-manager/src/main/java/org/openecomp/dcae/controller/service/cdap/cluster/servers/manager/DcaeCdapClusterManagerProvider.java
index 525412d..42d6955 100644
--- a/dcae-controller-service-cdap/dcae-controller-service-cdap-cluster/dcae-controller-service-cdap-cluster-manager/src/main/java/org/openecomp/dcae/controller/service/cdap/cluster/servers/manager/DcaeCdapClusterManagerProvider.java
+++ b/dcae-controller-service-cdap/dcae-controller-service-cdap-cluster/dcae-controller-service-cdap-cluster-manager/src/main/java/org/openecomp/dcae/controller/service/cdap/cluster/servers/manager/DcaeCdapClusterManagerProvider.java
@@ -52,7 +52,7 @@ public class DcaeCdapClusterManagerProvider extends DcaeVirtualMachineManagerPro
@Override
public HealthTestResponse test() {
String s = run(o.getHealthCheckScript(), o.getTestTimeout());
- String a[] = s.trim().split(":");
+ String[] a = s.trim().split(":");
int index = s.trim().indexOf(":");
String msg = index < 0 ? null : s.substring(index);
HealthTestResponse res = ServiceFactory.eINSTANCE.createHealthTestResponse();
diff --git a/dcae-controller-service-cdap/dcae-controller-service-cdap-cluster/dcae-controller-service-cdap-cluster-manager/src/main/sirius-gen/org/openecomp/dcae/controller/service/cdap/cluster/servers/manager/DcaeCdapClusterManagerConsole.java b/dcae-controller-service-cdap/dcae-controller-service-cdap-cluster/dcae-controller-service-cdap-cluster-manager/src/main/sirius-gen/org/openecomp/dcae/controller/service/cdap/cluster/servers/manager/DcaeCdapClusterManagerConsole.java
index 9a34e25..e2c72f6 100644
--- a/dcae-controller-service-cdap/dcae-controller-service-cdap-cluster/dcae-controller-service-cdap-cluster-manager/src/main/sirius-gen/org/openecomp/dcae/controller/service/cdap/cluster/servers/manager/DcaeCdapClusterManagerConsole.java
+++ b/dcae-controller-service-cdap/dcae-controller-service-cdap-cluster/dcae-controller-service-cdap-cluster-manager/src/main/sirius-gen/org/openecomp/dcae/controller/service/cdap/cluster/servers/manager/DcaeCdapClusterManagerConsole.java
@@ -18,7 +18,7 @@
* limitations under the License.
* ============LICENSE_END============================================
*/
-
+
// Autogenerated
// Do not edit but extend this class as needed
package org.openecomp.dcae.controller.service.cdap.cluster.servers.manager;
@@ -26,663 +26,602 @@ package org.openecomp.dcae.controller.service.cdap.cluster.servers.manager;
import org.apache.log4j.Logger;
import org.eclipse.emf.common.util.EList;
-
-import org.openecomp.ncomp.sirius.manager.console.Console;
+import org.openecomp.dcae.controller.service.cdap.cluster.servers.manager.gui.DcaeGuiClientApiConsole;
import org.openecomp.ncomp.sirius.manager.AbstractClient;
import org.openecomp.ncomp.sirius.manager.ManagementServerError;
-
-
-
-import org.openecomp.dcae.controller.service.cdap.cluster.servers.manager.gui.DcaeGuiClientApiConsole;
+import org.openecomp.ncomp.sirius.manager.console.Console;
public class DcaeCdapClusterManagerConsole extends Console {
- public static final Logger logger = Logger.getLogger(DcaeCdapClusterManagerConsole.class);
+ public static final Logger logger = Logger.getLogger(DcaeCdapClusterManagerConsole.class);
protected DcaeCdapClusterManagerClient controller;
-
-
- DcaeGuiClientApiConsole gui;
+
+
+ DcaeGuiClientApiConsole gui;
public DcaeCdapClusterManagerConsole(String filename, String name) {
- super(filename, name);
- controller = new DcaeCdapClusterManagerClient(filename,name);
- client = controller.client;
-
- gui = new DcaeGuiClientApiConsole(filename,name);
- }
-
- public DcaeCdapClusterManagerConsole(AbstractClient c) {
+ super(filename, name);
+ controller = new DcaeCdapClusterManagerClient(filename, name);
+ client = controller.client;
+
+ gui = new DcaeGuiClientApiConsole(filename, name);
+ }
+
+ public DcaeCdapClusterManagerConsole(AbstractClient c) {
controller = new DcaeCdapClusterManagerClient(c);
client = controller.client;
}
- public org.openecomp.dcae.controller.core.service.HealthTestResponse test() {
- org.openecomp.dcae.controller.core.service.HealthTestResponse res = null;
- try {
- res = controller.test();
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public void suspend() {
-
- try {
- controller.suspend();
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
-
- }
-
- public void resume() {
-
- try {
- controller.resume();
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
-
- }
-
- public java.lang.String publicKey() {
- java.lang.String res = null;
- try {
- res = controller.publicKey();
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public void configurationChanged() {
-
- try {
- controller.configurationChanged();
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
-
- }
-
- public void updateStreams(EList<org.openecomp.dcae.controller.core.stream.DcaeStream> inputStreams, EList<org.openecomp.dcae.controller.core.stream.DcaeStream> outputStreams) {
-
- try {
- controller.updateStreams(inputStreams,outputStreams);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
-
- }
-
- public void logs(EList<org.openecomp.ncomp.core.logs.LogMessage> logs) {
-
- try {
- controller.logs(null,logs);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
-
- }
-
- public void metrics(EList<org.openecomp.ncomp.core.metrics.Metric> metrics) {
-
- try {
- controller.metrics(null,metrics);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
-
- }
-
- public void properties(EList<org.openecomp.ncomp.sirius.manager.properties.AbstractProperty> l) {
-
- try {
- controller.properties(null,l);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
-
- }
-
- public void uploadInfo(EList<org.openecomp.ncomp.sirius.manager.server.ManagementInfo> info) {
-
- try {
- controller.uploadInfo(null,info);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
-
- }
-
- public EList<org.openecomp.ncomp.core.metrics.DoubleMetric> getValues(java.lang.String path, java.lang.Long start, java.lang.Long end, org.openecomp.ncomp.core.metrics.MetricValueOption option, boolean relativeInterval) {
- EList<org.openecomp.ncomp.core.metrics.DoubleMetric> res = null;
- try {
- res = controller.getValues(null,path,start,end,option,relativeInterval);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public EList<org.openecomp.ncomp.core.metrics.DoubleMetric> getValuesAll(java.lang.String path, EList<java.lang.String> metrics, java.lang.Long start, java.lang.Long end, org.openecomp.ncomp.core.metrics.MetricValueOption option, boolean relativeInterval) {
- EList<org.openecomp.ncomp.core.metrics.DoubleMetric> res = null;
- try {
- res = controller.getValuesAll(null,path,metrics,start,end,option,relativeInterval);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public EList<org.openecomp.ncomp.core.logs.LogMessage> getMessages(java.lang.String path, java.lang.Long start, java.lang.Long end) {
- EList<org.openecomp.ncomp.core.logs.LogMessage> res = null;
- try {
- res = controller.getMessages(null,path,start,end);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public org.openecomp.ncomp.sirius.manager.server.LoggerInfo getRequestLogger(java.lang.String userName, java.lang.String action, java.lang.String resourcePath, org.json.JSONObject context) {
- org.openecomp.ncomp.sirius.manager.server.LoggerInfo res = null;
- try {
- res = controller.getRequestLogger(userName,action,resourcePath,context);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public EList<org.openecomp.ncomp.core.function.ValuePair> evaluate(java.lang.String path, org.openecomp.ncomp.core.function.Function function) {
- EList<org.openecomp.ncomp.core.function.ValuePair> res = null;
- try {
- res = controller.evaluate(path,function);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public void update(java.lang.String path, org.openecomp.ncomp.core.function.Function function) {
-
- try {
- controller.update(path,function);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
-
- }
-
- public java.lang.String createNamespace(java.lang.String namespace) {
- java.lang.String res = null;
- try {
- res = controller.createNamespace(namespace);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String deleteNamespace(java.lang.String namespace) {
- java.lang.String res = null;
- try {
- res = controller.deleteNamespace(namespace);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String deployApp(java.lang.String namespace, java.lang.String jarfile) {
- java.lang.String res = null;
- try {
- res = controller.deployApp(namespace,jarfile);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String loadArtifact(java.lang.String namespace, java.lang.String artifactName, java.lang.String jarfile, java.lang.String version) {
- java.lang.String res = null;
- try {
- res = controller.loadArtifact(namespace,artifactName,jarfile,version);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String loadArtifactWithConfig(java.lang.String namespace, java.lang.String artifactName, java.lang.String jarfile, java.lang.String version, java.lang.String config) {
- java.lang.String res = null;
- try {
- res = controller.loadArtifactWithConfig(namespace,artifactName,jarfile,version,config);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String deleteArtifact(java.lang.String namespace, java.lang.String artifactName, java.lang.String artifactVersion) {
- java.lang.String res = null;
- try {
- res = controller.deleteArtifact(namespace,artifactName,artifactVersion);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String startFlow(java.lang.String namespace, java.lang.String appName, java.lang.String flowId, java.lang.String extraArgs) {
- java.lang.String res = null;
- try {
- res = controller.startFlow(namespace,appName,flowId,extraArgs);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String startWorker(java.lang.String namespace, java.lang.String appName, java.lang.String workerId, java.lang.String extraArgs) {
- java.lang.String res = null;
- try {
- res = controller.startWorker(namespace,appName,workerId,extraArgs);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String startService(java.lang.String namespace, java.lang.String appName, java.lang.String serviceId, java.lang.String extraArgs) {
- java.lang.String res = null;
- try {
- res = controller.startService(namespace,appName,serviceId,extraArgs);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String startApp(java.lang.String namespace, java.lang.String appName) {
- java.lang.String res = null;
- try {
- res = controller.startApp(namespace,appName);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String stopApp(java.lang.String namespace, java.lang.String appName, java.lang.String programTypes) {
- java.lang.String res = null;
- try {
- res = controller.stopApp(namespace,appName,programTypes);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String deleteApp(java.lang.String namespace, java.lang.String appName) {
- java.lang.String res = null;
- try {
- res = controller.deleteApp(namespace,appName);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String loadPreferencesApp(java.lang.String namespace, java.lang.String prefsFile, java.lang.String appId) {
- java.lang.String res = null;
- try {
- res = controller.loadPreferencesApp(namespace,prefsFile,appId);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String loadPreferencesFlow(java.lang.String namespace, java.lang.String prefsFile, java.lang.String appId, java.lang.String flowId) {
- java.lang.String res = null;
- try {
- res = controller.loadPreferencesFlow(namespace,prefsFile,appId,flowId);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String loadPreferencesNameSpace(java.lang.String namespace, java.lang.String prefsFile) {
- java.lang.String res = null;
- try {
- res = controller.loadPreferencesNameSpace(namespace,prefsFile);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String setPreferencesApp(java.lang.String namespace, java.lang.String prefsString, java.lang.String appId) {
- java.lang.String res = null;
- try {
- res = controller.setPreferencesApp(namespace,prefsString,appId);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String setPreferencesFlow(java.lang.String namespace, java.lang.String prefsString, java.lang.String appId, java.lang.String flowId) {
- java.lang.String res = null;
- try {
- res = controller.setPreferencesFlow(namespace,prefsString,appId,flowId);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String setPreferencesWorker(java.lang.String namespace, java.lang.String prefsString, java.lang.String appId, java.lang.String workerId) {
- java.lang.String res = null;
- try {
- res = controller.setPreferencesWorker(namespace,prefsString,appId,workerId);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String setPreferencesService(java.lang.String namespace, java.lang.String prefsString, java.lang.String appId, java.lang.String serviceId) {
- java.lang.String res = null;
- try {
- res = controller.setPreferencesService(namespace,prefsString,appId,serviceId);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String setPreferencesNameSpace(java.lang.String namespace, java.lang.String prefsString) {
- java.lang.String res = null;
- try {
- res = controller.setPreferencesNameSpace(namespace,prefsString);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String setFlowRunTimeArgs(java.lang.String namespace, java.lang.String appId, java.lang.String flowId, java.lang.String args) {
- java.lang.String res = null;
- try {
- res = controller.setFlowRunTimeArgs(namespace,appId,flowId,args);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String setFlowletInstances(java.lang.String namespace, java.lang.String appId, java.lang.String flowId, java.lang.String flowletId, int nInstances) {
- java.lang.String res = null;
- try {
- res = controller.setFlowletInstances(namespace,appId,flowId,flowletId,nInstances);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String stopFlow(java.lang.String namespace, java.lang.String appId, java.lang.String flowId) {
- java.lang.String res = null;
- try {
- res = controller.stopFlow(namespace,appId,flowId);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String stopWorker(java.lang.String namespace, java.lang.String appId, java.lang.String workerId) {
- java.lang.String res = null;
- try {
- res = controller.stopWorker(namespace,appId,workerId);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String stopService(java.lang.String namespace, java.lang.String appId, java.lang.String serviceId) {
- java.lang.String res = null;
- try {
- res = controller.stopService(namespace,appId,serviceId);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String truncateDataSet(java.lang.String namespace, java.lang.String datasetName) {
- java.lang.String res = null;
- try {
- res = controller.truncateDataSet(namespace,datasetName);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String deleteDataset(java.lang.String namespace, java.lang.String datasetName) {
- java.lang.String res = null;
- try {
- res = controller.deleteDataset(namespace,datasetName);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String createStream(java.lang.String namespace, java.lang.String newStreamId) {
- java.lang.String res = null;
- try {
- res = controller.createStream(namespace,newStreamId);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String deleteStream(java.lang.String namespace, java.lang.String streamId) {
- java.lang.String res = null;
- try {
- res = controller.deleteStream(namespace,streamId);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public EList<java.lang.String> getStreamEvents(java.lang.String namespace, java.lang.String streamId, java.lang.String startTime, java.lang.String endTime, int limit) {
- EList<java.lang.String> res = null;
- try {
- res = controller.getStreamEvents(namespace,streamId,startTime,endTime,limit);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public EList<java.lang.String> getStreamStats(java.lang.String namespace, java.lang.String streamId, java.lang.String startTime, java.lang.String endTime, int limit) {
- EList<java.lang.String> res = null;
- try {
- res = controller.getStreamStats(namespace,streamId,startTime,endTime,limit);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String sendEventToStream(java.lang.String namespace, java.lang.String streamId, java.lang.String event) {
- java.lang.String res = null;
- try {
- res = controller.sendEventToStream(namespace,streamId,event);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String trucateStream(java.lang.String namespace, java.lang.String streamId) {
- java.lang.String res = null;
- try {
- res = controller.trucateStream(namespace,streamId);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String setStreamProperties(java.lang.String namespace, java.lang.String streamId, java.lang.String propsFile) {
- java.lang.String res = null;
- try {
- res = controller.setStreamProperties(namespace,streamId,propsFile);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String restartApp(java.lang.String namespace, java.lang.String appId, java.lang.String progTypes) {
- java.lang.String res = null;
- try {
- res = controller.restartApp(namespace,appId,progTypes);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String createApp(java.lang.String namespace, java.lang.String appId, java.lang.String artifactName, java.lang.String artifactVersion, java.lang.String scope) {
- java.lang.String res = null;
- try {
- res = controller.createApp(namespace,appId,artifactName,artifactVersion,scope);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String createAppWithConfig(java.lang.String namespace, java.lang.String appId, java.lang.String artifactName, java.lang.String artifactVersion, java.lang.String scope, java.lang.String appConfig) {
- java.lang.String res = null;
- try {
- res = controller.createAppWithConfig(namespace,appId,artifactName,artifactVersion,scope,appConfig);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String setDatasetProperties(java.lang.String namespace, java.lang.String datasetName, java.lang.String datasetProperties) {
- java.lang.String res = null;
- try {
- res = controller.setDatasetProperties(namespace,datasetName,datasetProperties);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String setStreamTTL(java.lang.String namespace, java.lang.String streamName, int ttlSeconds) {
- java.lang.String res = null;
- try {
- res = controller.setStreamTTL(namespace,streamName,ttlSeconds);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String suspendSchedule(java.lang.String namespace, java.lang.String appId, java.lang.String scheduleId) {
- java.lang.String res = null;
- try {
- res = controller.suspendSchedule(namespace,appId,scheduleId);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
-
- public java.lang.String resumeSchedule(java.lang.String namespace, java.lang.String appId, java.lang.String scheduleId) {
- java.lang.String res = null;
- try {
- res = controller.resumeSchedule(namespace,appId,scheduleId);
- }
- catch (ManagementServerError e) {
- System.err.println("ERROR: " + e.getJson().toString(2));
- }
- return res;
- }
+ public org.openecomp.dcae.controller.core.service.HealthTestResponse test() {
+ org.openecomp.dcae.controller.core.service.HealthTestResponse res = null;
+ try {
+ res = controller.test();
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public void suspend() {
+
+ try {
+ controller.suspend();
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+
+ }
+
+ public void resume() {
+
+ try {
+ controller.resume();
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+
+ }
+
+ public java.lang.String publicKey() {
+ java.lang.String res = null;
+ try {
+ res = controller.publicKey();
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public void configurationChanged() {
+
+ try {
+ controller.configurationChanged();
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+
+ }
+
+ public void updateStreams(EList<org.openecomp.dcae.controller.core.stream.DcaeStream> inputStreams, EList<org.openecomp.dcae.controller.core.stream.DcaeStream> outputStreams) {
+
+ try {
+ controller.updateStreams(inputStreams, outputStreams);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+
+ }
+
+ public void logs(EList<org.openecomp.ncomp.core.logs.LogMessage> logs) {
+
+ try {
+ controller.logs(null, logs);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+
+ }
+
+ public void metrics(EList<org.openecomp.ncomp.core.metrics.Metric> metrics) {
+
+ try {
+ controller.metrics(null, metrics);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+
+ }
+
+ public void properties(EList<org.openecomp.ncomp.sirius.manager.properties.AbstractProperty> l) {
+
+ try {
+ controller.properties(null, l);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+
+ }
+
+ public void uploadInfo(EList<org.openecomp.ncomp.sirius.manager.server.ManagementInfo> info) {
+
+ try {
+ controller.uploadInfo(null, info);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+
+ }
+
+ public EList<org.openecomp.ncomp.core.metrics.DoubleMetric> getValues(java.lang.String path, java.lang.Long start, java.lang.Long end, org.openecomp.ncomp.core.metrics.MetricValueOption option, boolean relativeInterval) {
+ EList<org.openecomp.ncomp.core.metrics.DoubleMetric> res = null;
+ try {
+ res = controller.getValues(null, path, start, end, option, relativeInterval);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public EList<org.openecomp.ncomp.core.metrics.DoubleMetric> getValuesAll(java.lang.String path, EList<java.lang.String> metrics, java.lang.Long start, java.lang.Long end, org.openecomp.ncomp.core.metrics.MetricValueOption option, boolean relativeInterval) {
+ EList<org.openecomp.ncomp.core.metrics.DoubleMetric> res = null;
+ try {
+ res = controller.getValuesAll(null, path, metrics, start, end, option, relativeInterval);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public EList<org.openecomp.ncomp.core.logs.LogMessage> getMessages(java.lang.String path, java.lang.Long start, java.lang.Long end) {
+ EList<org.openecomp.ncomp.core.logs.LogMessage> res = null;
+ try {
+ res = controller.getMessages(null, path, start, end);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public org.openecomp.ncomp.sirius.manager.server.LoggerInfo getRequestLogger(java.lang.String userName, java.lang.String action, java.lang.String resourcePath, org.json.JSONObject context) {
+ org.openecomp.ncomp.sirius.manager.server.LoggerInfo res = null;
+ try {
+ res = controller.getRequestLogger(userName, action, resourcePath, context);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public EList<org.openecomp.ncomp.core.function.ValuePair> evaluate(java.lang.String path, org.openecomp.ncomp.core.function.Function function) {
+ EList<org.openecomp.ncomp.core.function.ValuePair> res = null;
+ try {
+ res = controller.evaluate(path, function);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public void update(java.lang.String path, org.openecomp.ncomp.core.function.Function function) {
+
+ try {
+ controller.update(path, function);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+
+ }
+
+ public java.lang.String createNamespace(java.lang.String namespace) {
+ java.lang.String res = null;
+ try {
+ res = controller.createNamespace(namespace);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String deleteNamespace(java.lang.String namespace) {
+ java.lang.String res = null;
+ try {
+ res = controller.deleteNamespace(namespace);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String deployApp(java.lang.String namespace, java.lang.String jarfile) {
+ java.lang.String res = null;
+ try {
+ res = controller.deployApp(namespace, jarfile);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String loadArtifact(java.lang.String namespace, java.lang.String artifactName, java.lang.String jarfile, java.lang.String version) {
+ java.lang.String res = null;
+ try {
+ res = controller.loadArtifact(namespace, artifactName, jarfile, version);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String loadArtifactWithConfig(java.lang.String namespace, java.lang.String artifactName, java.lang.String jarfile, java.lang.String version, java.lang.String config) {
+ java.lang.String res = null;
+ try {
+ res = controller.loadArtifactWithConfig(namespace, artifactName, jarfile, version, config);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String deleteArtifact(java.lang.String namespace, java.lang.String artifactName, java.lang.String artifactVersion) {
+ java.lang.String res = null;
+ try {
+ res = controller.deleteArtifact(namespace, artifactName, artifactVersion);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String startFlow(java.lang.String namespace, java.lang.String appName, java.lang.String flowId, java.lang.String extraArgs) {
+ java.lang.String res = null;
+ try {
+ res = controller.startFlow(namespace, appName, flowId, extraArgs);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String startWorker(java.lang.String namespace, java.lang.String appName, java.lang.String workerId, java.lang.String extraArgs) {
+ java.lang.String res = null;
+ try {
+ res = controller.startWorker(namespace, appName, workerId, extraArgs);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String startService(java.lang.String namespace, java.lang.String appName, java.lang.String serviceId, java.lang.String extraArgs) {
+ java.lang.String res = null;
+ try {
+ res = controller.startService(namespace, appName, serviceId, extraArgs);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String startApp(java.lang.String namespace, java.lang.String appName) {
+ java.lang.String res = null;
+ try {
+ res = controller.startApp(namespace, appName);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String stopApp(java.lang.String namespace, java.lang.String appName, java.lang.String programTypes) {
+ java.lang.String res = null;
+ try {
+ res = controller.stopApp(namespace, appName, programTypes);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String deleteApp(java.lang.String namespace, java.lang.String appName) {
+ java.lang.String res = null;
+ try {
+ res = controller.deleteApp(namespace, appName);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String loadPreferencesApp(java.lang.String namespace, java.lang.String prefsFile, java.lang.String appId) {
+ java.lang.String res = null;
+ try {
+ res = controller.loadPreferencesApp(namespace, prefsFile, appId);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String loadPreferencesFlow(java.lang.String namespace, java.lang.String prefsFile, java.lang.String appId, java.lang.String flowId) {
+ java.lang.String res = null;
+ try {
+ res = controller.loadPreferencesFlow(namespace, prefsFile, appId, flowId);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String loadPreferencesNameSpace(java.lang.String namespace, java.lang.String prefsFile) {
+ java.lang.String res = null;
+ try {
+ res = controller.loadPreferencesNameSpace(namespace, prefsFile);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String setPreferencesApp(java.lang.String namespace, java.lang.String prefsString, java.lang.String appId) {
+ java.lang.String res = null;
+ try {
+ res = controller.setPreferencesApp(namespace, prefsString, appId);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String setPreferencesFlow(java.lang.String namespace, java.lang.String prefsString, java.lang.String appId, java.lang.String flowId) {
+ java.lang.String res = null;
+ try {
+ res = controller.setPreferencesFlow(namespace, prefsString, appId, flowId);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String setPreferencesWorker(java.lang.String namespace, java.lang.String prefsString, java.lang.String appId, java.lang.String workerId) {
+ java.lang.String res = null;
+ try {
+ res = controller.setPreferencesWorker(namespace, prefsString, appId, workerId);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String setPreferencesService(java.lang.String namespace, java.lang.String prefsString, java.lang.String appId, java.lang.String serviceId) {
+ java.lang.String res = null;
+ try {
+ res = controller.setPreferencesService(namespace, prefsString, appId, serviceId);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String setPreferencesNameSpace(java.lang.String namespace, java.lang.String prefsString) {
+ java.lang.String res = null;
+ try {
+ res = controller.setPreferencesNameSpace(namespace, prefsString);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String setFlowRunTimeArgs(java.lang.String namespace, java.lang.String appId, java.lang.String flowId, java.lang.String args) {
+ java.lang.String res = null;
+ try {
+ res = controller.setFlowRunTimeArgs(namespace, appId, flowId, args);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String setFlowletInstances(java.lang.String namespace, java.lang.String appId, java.lang.String flowId, java.lang.String flowletId, int nInstances) {
+ java.lang.String res = null;
+ try {
+ res = controller.setFlowletInstances(namespace, appId, flowId, flowletId, nInstances);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String stopFlow(java.lang.String namespace, java.lang.String appId, java.lang.String flowId) {
+ java.lang.String res = null;
+ try {
+ res = controller.stopFlow(namespace, appId, flowId);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String stopWorker(java.lang.String namespace, java.lang.String appId, java.lang.String workerId) {
+ java.lang.String res = null;
+ try {
+ res = controller.stopWorker(namespace, appId, workerId);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String stopService(java.lang.String namespace, java.lang.String appId, java.lang.String serviceId) {
+ java.lang.String res = null;
+ try {
+ res = controller.stopService(namespace, appId, serviceId);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String truncateDataSet(java.lang.String namespace, java.lang.String datasetName) {
+ java.lang.String res = null;
+ try {
+ res = controller.truncateDataSet(namespace, datasetName);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String deleteDataset(java.lang.String namespace, java.lang.String datasetName) {
+ java.lang.String res = null;
+ try {
+ res = controller.deleteDataset(namespace, datasetName);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String createStream(java.lang.String namespace, java.lang.String newStreamId) {
+ java.lang.String res = null;
+ try {
+ res = controller.createStream(namespace, newStreamId);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String deleteStream(java.lang.String namespace, java.lang.String streamId) {
+ java.lang.String res = null;
+ try {
+ res = controller.deleteStream(namespace, streamId);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public EList<java.lang.String> getStreamEvents(java.lang.String namespace, java.lang.String streamId, java.lang.String startTime, java.lang.String endTime, int limit) {
+ EList<java.lang.String> res = null;
+ try {
+ res = controller.getStreamEvents(namespace, streamId, startTime, endTime, limit);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public EList<java.lang.String> getStreamStats(java.lang.String namespace, java.lang.String streamId, java.lang.String startTime, java.lang.String endTime, int limit) {
+ EList<java.lang.String> res = null;
+ try {
+ res = controller.getStreamStats(namespace, streamId, startTime, endTime, limit);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String sendEventToStream(java.lang.String namespace, java.lang.String streamId, java.lang.String event) {
+ java.lang.String res = null;
+ try {
+ res = controller.sendEventToStream(namespace, streamId, event);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String trucateStream(java.lang.String namespace, java.lang.String streamId) {
+ java.lang.String res = null;
+ try {
+ res = controller.trucateStream(namespace, streamId);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String setStreamProperties(java.lang.String namespace, java.lang.String streamId, java.lang.String propsFile) {
+ java.lang.String res = null;
+ try {
+ res = controller.setStreamProperties(namespace, streamId, propsFile);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String restartApp(java.lang.String namespace, java.lang.String appId, java.lang.String progTypes) {
+ java.lang.String res = null;
+ try {
+ res = controller.restartApp(namespace, appId, progTypes);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String createApp(java.lang.String namespace, java.lang.String appId, java.lang.String artifactName, java.lang.String artifactVersion, java.lang.String scope) {
+ java.lang.String res = null;
+ try {
+ res = controller.createApp(namespace, appId, artifactName, artifactVersion, scope);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String createAppWithConfig(java.lang.String namespace, java.lang.String appId, java.lang.String artifactName, java.lang.String artifactVersion, java.lang.String scope, java.lang.String appConfig) {
+ java.lang.String res = null;
+ try {
+ res = controller.createAppWithConfig(namespace, appId, artifactName, artifactVersion, scope, appConfig);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String setDatasetProperties(java.lang.String namespace, java.lang.String datasetName, java.lang.String datasetProperties) {
+ java.lang.String res = null;
+ try {
+ res = controller.setDatasetProperties(namespace, datasetName, datasetProperties);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String setStreamTTL(java.lang.String namespace, java.lang.String streamName, int ttlSeconds) {
+ java.lang.String res = null;
+ try {
+ res = controller.setStreamTTL(namespace, streamName, ttlSeconds);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String suspendSchedule(java.lang.String namespace, java.lang.String appId, java.lang.String scheduleId) {
+ java.lang.String res = null;
+ try {
+ res = controller.suspendSchedule(namespace, appId, scheduleId);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
+
+ public java.lang.String resumeSchedule(java.lang.String namespace, java.lang.String appId, java.lang.String scheduleId) {
+ java.lang.String res = null;
+ try {
+ res = controller.resumeSchedule(namespace, appId, scheduleId);
+ } catch (ManagementServerError e) {
+ logger.error("ERROR: " + e.getJson().toString(2), e);
+ }
+ return res;
+ }
}
diff --git a/dcae-controller-service-docker/dcae-controller-service-docker-adaptor/src/main/java/org/openecomp/dcae/controller/service/servers/docker/DcaeDockerServiceProvider.java b/dcae-controller-service-docker/dcae-controller-service-docker-adaptor/src/main/java/org/openecomp/dcae/controller/service/servers/docker/DcaeDockerServiceProvider.java
index 883ec7b..6d27af3 100644
--- a/dcae-controller-service-docker/dcae-controller-service-docker-adaptor/src/main/java/org/openecomp/dcae/controller/service/servers/docker/DcaeDockerServiceProvider.java
+++ b/dcae-controller-service-docker/dcae-controller-service-docker-adaptor/src/main/java/org/openecomp/dcae/controller/service/servers/docker/DcaeDockerServiceProvider.java
@@ -18,10 +18,8 @@
* limitations under the License.
* ============LICENSE_END============================================
*/
-
-package org.openecomp.dcae.controller.service.servers.docker;
-import java.util.Date;
+package org.openecomp.dcae.controller.service.servers.docker;
import org.apache.log4j.Logger;
import org.eclipse.emf.common.util.BasicEList;
@@ -29,8 +27,6 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.json.JSONObject;
-
-import org.openecomp.dcae.controller.core.service.DcaeServiceContainer;
import org.openecomp.dcae.controller.core.service.HealthTestResponse;
import org.openecomp.dcae.controller.core.service.HealthTestStatus;
import org.openecomp.dcae.controller.core.service.ServiceFactory;
@@ -38,15 +34,10 @@ import org.openecomp.dcae.controller.core.stream.DcaeStream;
import org.openecomp.dcae.controller.core.stream.DmaapStream;
import org.openecomp.dcae.controller.service.docker.DockerService;
import org.openecomp.dcae.controller.service.docker.DockerServiceInstance;
-import org.openecomp.dcae.controller.service.docker.host.servers.manager.DcaeDockerHostManager;
import org.openecomp.dcae.controller.service.docker.host.servers.manager.DcaeDockerHostManagerConsole;
-import org.openecomp.dcae.controller.service.docker.host.servers.service.DcaeDockerHostService;
import org.openecomp.dcae.controller.service.docker.host.servers.service.DcaeDockerHostServiceProvider;
import org.openecomp.dcae.controller.service.docker.host.service.DockerHostServiceInstance;
-import org.openecomp.dcae.controller.service.servers.dockermanager.DcaeDockerManagerConsole;
-import org.openecomp.dcae.controller.service.servers.vmmanager.DcaeVirtualMachineManagerConsole;
import org.openecomp.dcae.controller.service.vm.VirtualMachineService;
-import org.openecomp.dcae.controller.service.vm.VirtualMachineServiceInstance;
import org.openecomp.ncomp.core.DeploymentStatus;
import org.openecomp.ncomp.docker.ContainerOptions;
import org.openecomp.ncomp.docker.ContainerPortBindings;
@@ -62,289 +53,295 @@ import org.openecomp.ncomp.sirius.manager.ManagementServer;
import org.openecomp.ncomp.sirius.manager.ManagementServerUtils;
import org.openecomp.ncomp.sirius.manager.Subject;
import org.openecomp.ncomp.sirius.manager.metrics.MetricStore;
-import org.openecomp.ncomp.utils.CryptoUtils;
+
+import java.util.Date;
public class DcaeDockerServiceProvider extends BasicAdaptorProvider {
- private static final Logger logger = Logger.getLogger(DcaeDockerServiceProvider.class);
- DockerService o;
-
- public DcaeDockerServiceProvider(ISiriusServer controller, DockerService o) {
- super(controller, o);
- this.o = o;
- }
-
- public void deploy(String instanceName, String containerPath) {
- DockerServiceInstance i = findInstance(instanceName);
- if (!(containerPath == null || containerPath.equals(""))) {
- Subject s = controller.getServer().find(containerPath);
- if (s == null || s.o == null) {
- throw new RuntimeException("Unable to find container object: " + containerPath);
- }
- if (!(s.o instanceof DockerHostServiceInstance))
- throw new RuntimeException("Unable to deploy to this non docker host container: " + containerPath);
- i.setHostService((DockerHostServiceInstance) s.o);
- }
- if (i.getHostService() == null) {
- throw new RuntimeException("Null Container: unable to deploy: " + o.getName() + " " + i.getName());
- }
- i.setDockerName(dockerName(i));
- ContainerOptions opts = DockerFactory.eINSTANCE.createContainerOptions();
- opts.setName(i.getDockerName());
- opts.getVolumes().addAll(i.getVolumes());
- opts.getLinks().addAll(i.getLinks());
- opts.getEnv().addAll(i.getEnvs());
- for (ContainerPortBindings p : i.getPortBindings()) {
- opts.getPortBindings().add(EcoreUtil.copy(p));
- }
- console(instanceName).setupConfiguration(o.getName(), instanceName);
- consoleHost(i).dockerRunWithOptions("/resources/dockerHost", image(i), opts);
- long toolate = System.currentTimeMillis() + 15 * 60 * 1000;
- // wait 15 minutes for container manager
- while (i.getManagerPortNumber() > 0 && System.currentTimeMillis() < toolate) {
- try {
- o.pushManagerConfiguration(instanceName);
- break;
- } catch (Exception e) {
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e1) {
- throw new RuntimeException("Deployment timeout: Deployment interrupted");
- }
- }
- if (System.currentTimeMillis() >= toolate)
- throw new RuntimeException("Unable to configure Docker");
- }
- }
-
- private String image(DockerServiceInstance i) {
- if (i.getImage().contains("/"))
- return i.getImage();
- String dns = i.getHostService().getServers().get(0).getNetworks().get(0).getDnsName();
- return dns + ":7113/" + i.getImage();
- }
-
- public void undeploy(String instanceName) {
- DockerServiceInstance i = findInstance(instanceName);
- DockerDockerHostConsole c = consoleHost(i);
+ private static final Logger logger = Logger.getLogger(DcaeDockerServiceProvider.class);
+ DockerService o;
+
+ public DcaeDockerServiceProvider(ISiriusServer controller, DockerService o) {
+ super(controller, o);
+ this.o = o;
+ }
+
+ public void deploy(String instanceName, String containerPath) {
+ DockerServiceInstance i = findInstance(instanceName);
+ if (!(containerPath == null || containerPath.equals(""))) {
+ Subject s = controller.getServer().find(containerPath);
+ if (s == null || s.o == null) {
+ throw new RuntimeException("Unable to find container object: " + containerPath);
+ }
+ if (!(s.o instanceof DockerHostServiceInstance)) {
+ throw new RuntimeException("Unable to deploy to this non docker host container: " + containerPath);
+ }
+ i.setHostService((DockerHostServiceInstance) s.o);
+ }
+ if (i.getHostService() == null) {
+ throw new RuntimeException("Null Container: unable to deploy: " + o.getName() + " " + i.getName());
+ }
+ i.setDockerName(dockerName(i));
+ ContainerOptions opts = DockerFactory.eINSTANCE.createContainerOptions();
+ opts.setName(i.getDockerName());
+ opts.getVolumes().addAll(i.getVolumes());
+ opts.getLinks().addAll(i.getLinks());
+ opts.getEnv().addAll(i.getEnvs());
+ for (ContainerPortBindings p : i.getPortBindings()) {
+ opts.getPortBindings().add(EcoreUtil.copy(p));
+ }
+ console(instanceName).setupConfiguration(o.getName(), instanceName);
+ consoleHost(i).dockerRunWithOptions("/resources/dockerHost", image(i), opts);
+ long toolate = System.currentTimeMillis() + 15 * 60 * 1000;
+ // wait 15 minutes for container manager
+ while (i.getManagerPortNumber() > 0 && System.currentTimeMillis() < toolate) {
+ try {
+ o.pushManagerConfiguration(instanceName);
+ break;
+ } catch (Exception e) {
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e1) {
+ throw new RuntimeException("Deployment timeout: Deployment interrupted");
+ }
+ }
+ if (System.currentTimeMillis() >= toolate) {
+ throw new RuntimeException("Unable to configure Docker");
+ }
+ }
+ }
+
+ private String image(DockerServiceInstance i) {
+ if (i.getImage().contains("/")) {
+ return i.getImage();
+ }
+ String dns = i.getHostService().getServers().get(0).getNetworks().get(0).getDnsName();
+ return dns + ":7113/" + i.getImage();
+ }
+
+ public void undeploy(String instanceName) {
+ DockerServiceInstance i = findInstance(instanceName);
+ DockerDockerHostConsole c = consoleHost(i);
// c.stopContainer("/resources/dockerHost", i.getDockerName(), 10);
// c.killContainer("/resources/dockerHost", i.getDockerName(), "KILL");
- c.removeContainer("/resources/dockerHost", i.getDockerName(), true, true);
- }
-
- private DcaeDockerHostManagerConsole console(String instanceName) {
- DockerServiceInstance i = findInstance(instanceName);
- return new DcaeDockerHostManagerConsole(getClient(i));
- }
-
- public AbstractClient getClient(DockerServiceInstance i) {
- DockerHostServiceInstance instance = i.getHostService();
- VirtualMachineService service = instance.getService();
- DcaeDockerHostServiceProvider provider = (DcaeDockerHostServiceProvider) ((ISiriusProvider) service).getSiriusProvider();
- return provider.getClient(instance);
- }
-
- private DockerDockerHostConsole consoleHost(DockerServiceInstance i) {
- DockerHostServiceInstance instance = i.getHostService();
- VirtualMachineService service = instance.getService();
- DcaeDockerHostServiceProvider provider = (DcaeDockerHostServiceProvider) ((ISiriusProvider) service).getSiriusProvider();
- AbstractClient c = provider.getClient(instance);
- return new DockerDockerHostConsole(c);
- }
-
- private String dockerName(DockerServiceInstance i) {
- return "dcae_" + o.getName() + "_" + i.getName();
- // return "dcae"+ new Date().getTime();
- }
-
- protected DockerServiceInstance findInstance(String instanceName) {
- for (DockerServiceInstance ii : o.getInstances()) {
- if (ii.getName().equals(instanceName)) {
- ii.setDockerName(dockerName(ii));
- return ii;
- }
- }
- throw new RuntimeException("Unable to find instance: " + instanceName);
-
- }
-
- public HealthTestResponse test(String instanceName) {
- DockerServiceInstance i = findInstance(instanceName);
- DockerContainer c = findContainer(i);
- HealthTestResponse h = ServiceFactory.eINSTANCE.createHealthTestResponse();
- if (c == null) {
- h.setStatus(HealthTestStatus.YELLOW);
- h.setMessageCode("Container not Deployed");
- return h;
- }
- System.out.println("DOCKER: test" + i.getDockerName() + " " + c.getStatus());
- if (c.getStatus().startsWith("Exited")) {
- h.setStatus(HealthTestStatus.RED);
- h.setMessageCode("Container not running");
- return h;
- }
- if (c.getStatus().startsWith("Created")) {
- h.setStatus(HealthTestStatus.RED);
- h.setMessageCode("Container never started");
- return h;
- }
- if (c.getStatus().startsWith("Restarting")) {
- h.setStatus(HealthTestStatus.RED);
- h.setMessageCode("Container restarting");
- return h;
- }
- if (i.getManagerPortNumber() > 0) {
- System.out.println("DOCKER: test" + i.getDockerName() + "HERE");
- return console(instanceName).testContainer(i.getDockerName());
- }
- h.setStatus(HealthTestStatus.GREEN);
- return h;
- }
-
- public void suspend(String instanceName) {
- DockerServiceInstance i = findInstance(instanceName);
- console(instanceName).suspendContainer(i.getDockerName());
- }
-
- public void resume(String instanceName) {
- DockerServiceInstance i = findInstance(instanceName);
- console(instanceName).resumeContainer(i.getDockerName());
- }
-
- public void pushManagerConfiguration(String instanceName) {
- DockerServiceInstance i = findInstance(instanceName);
- DcaeDockerHostManagerConsole console = console(instanceName);
- EObject config = o.managerConfiguration(instanceName);
- System.out.println("DDDDD " + ManagementServer.ecore2json(config, 1000, null, true).toString(2));
- EList<DcaeStream> l1 = new BasicEList<DcaeStream>();
- l1.addAll(EcoreUtil.copyAll(i.getInputStreams()));
- EList<DcaeStream> l2 = new BasicEList<DcaeStream>();
- l2.addAll(EcoreUtil.copyAll(i.getOutputStreams()));
- console.updateContainerConfiguration(i.getDockerName(), config, decrypt(l1), decrypt(l2));
- }
-
- private EList<DcaeStream> decrypt(EList<DcaeStream> l) {
- for (DcaeStream s : l) {
- if (s instanceof DmaapStream) {
- DmaapStream s1 = (DmaapStream) s;
- String pw = s1.getDmaapPassword();
- if (pw != null && pw.startsWith("rsa:")) {
- try {
- s1.setDmaapPassword(JavaHttpClient.decryptPassword(pw));
- } catch (Exception e) {
- System.err.println("ZZZZZ: bad pw: " + ManagementServer.object2ref(s));
- s1.setDmaapPassword("decryption error");
- }
- }
- else
- System.err.println("ZZZZZ: unencrypted pw: " + ManagementServer.object2ref(s));
- continue;
- }
- System.err.println("ZZZZZ: unknown type: " + s.getClass().getName());
- }
- return l;
- }
-
- public void pollManagerConfiguration(String instanceName) {
-
- // TODO IMPLEMENT
- throw new UnsupportedOperationException();
- }
-
- public org.eclipse.emf.ecore.EObject managerConfiguration(String instanceName) {
- // TODO IMPLEMENT
- throw new UnsupportedOperationException();
- }
-
- public JSONObject managerOperation(String instanceName, String operation, JSONObject parameters) {
- // TODO IMPLEMENT
- throw new UnsupportedOperationException();
- }
-
- public void updateConfigurationFromPolicy(String instanceName) {
-
- // TODO IMPLEMENT
- throw new UnsupportedOperationException();
- }
-
- public void runHealthTests() {
-// System.out.println("DOCKER: runHealthTests" + o.getName());
- for (DockerServiceInstance i : o.getInstances()) {
- HealthTestResponse s = null;
- try {
- if (i.getStatus() == DeploymentStatus.DEPLOYED) {
- s = test(i.getName());
- } else {
- s = ServiceFactory.eINSTANCE.createHealthTestResponse();
- s.setMessageCode("Not deployed");
- s.setStatus(HealthTestStatus.YELLOW);
- }
- } catch (Exception e) {
- s = ServiceFactory.eINSTANCE.createHealthTestResponse();
- s.setMessageCode("Unable to determine health: " + e);
- s.setStatus(HealthTestStatus.RED);
- }
- i.setHealthTestStatus(s.getStatus());
- i.setHealthTestMessageCode(s.getMessageCode());
- MetricStore store = controller.getServer().metrics.getStore(i);
- Date now = new Date();
- String path = "/lastHealthTest";
- store.addLongValue(path, now, now.getTime(), "DateMetricAttribute", false);
- }
- }
-
- public void start() {
-
- Thread t = new Thread("docker service: " + o.getName()) {
- @Override
- public void run() {
- while (true) {
- try {
- if (! controller.getServer().isSlave)
- updateDeploymentStatus();
- Thread.sleep(60000); // sleep 60 seconds
- } catch (Exception e) {
- ManagementServerUtils.printStackTrace(e);
- logger.fatal("vm service: " + o.getName() + " : " + e);
- try {
- Thread.sleep(30000);
- } catch (InterruptedException e1) {
- }
- }
- }
- }
-
- };
- t.start();
- }
-
- public void updateDeploymentStatus() {
- for (DockerServiceInstance instance : o.getInstances()) {
- instance.setDockerName(dockerName(instance));
- DockerContainer c = findContainer(instance);
- if (c != null) {
- if (c.getStatus() != null && c.getStatus().startsWith("Up"))
- instance.setStatus(DeploymentStatus.DEPLOYED);
- else
- instance.setStatus(DeploymentStatus.DEPLOYED_PARTIALLY);
- }
- else
- instance.setStatus(DeploymentStatus.UNDEPLOYED);
- }
- }
-
- private DockerContainer findContainer(DockerServiceInstance instance) {
- if (instance.getHostService() == null)
- return null;
- for (DockerContainer c : instance.getHostService().getDockerHost().getContainers()) {
- if (instance.getDockerName() != null && instance.getDockerName().equals(c.getName())) {
- return c;
- }
- }
- return null;
- }
-
- protected EObject convertToManagerConfiguration(DockerServiceInstance i) {
- // TODO Auto-generated method stub
- return null;
- }
+ c.removeContainer("/resources/dockerHost", i.getDockerName(), true, true);
+ }
+
+ private DcaeDockerHostManagerConsole console(String instanceName) {
+ DockerServiceInstance i = findInstance(instanceName);
+ return new DcaeDockerHostManagerConsole(getClient(i));
+ }
+
+ public AbstractClient getClient(DockerServiceInstance i) {
+ DockerHostServiceInstance instance = i.getHostService();
+ VirtualMachineService service = instance.getService();
+ DcaeDockerHostServiceProvider provider = (DcaeDockerHostServiceProvider) ((ISiriusProvider) service).getSiriusProvider();
+ return provider.getClient(instance);
+ }
+
+ private DockerDockerHostConsole consoleHost(DockerServiceInstance i) {
+ DockerHostServiceInstance instance = i.getHostService();
+ VirtualMachineService service = instance.getService();
+ DcaeDockerHostServiceProvider provider = (DcaeDockerHostServiceProvider) ((ISiriusProvider) service).getSiriusProvider();
+ AbstractClient c = provider.getClient(instance);
+ return new DockerDockerHostConsole(c);
+ }
+
+ private String dockerName(DockerServiceInstance i) {
+ return "dcae_" + o.getName() + "_" + i.getName();
+ // return "dcae"+ new Date().getTime();
+ }
+
+ protected DockerServiceInstance findInstance(String instanceName) {
+ for (DockerServiceInstance ii : o.getInstances()) {
+ if (ii.getName().equals(instanceName)) {
+ ii.setDockerName(dockerName(ii));
+ return ii;
+ }
+ }
+ throw new RuntimeException("Unable to find instance: " + instanceName);
+
+ }
+
+ public HealthTestResponse test(String instanceName) {
+ DockerServiceInstance i = findInstance(instanceName);
+ DockerContainer c = findContainer(i);
+ HealthTestResponse h = ServiceFactory.eINSTANCE.createHealthTestResponse();
+ if (c == null) {
+ h.setStatus(HealthTestStatus.YELLOW);
+ h.setMessageCode("Container not Deployed");
+ return h;
+ }
+ System.out.println("DOCKER: test" + i.getDockerName() + " " + c.getStatus());
+ if (c.getStatus().startsWith("Exited")) {
+ h.setStatus(HealthTestStatus.RED);
+ h.setMessageCode("Container not running");
+ return h;
+ }
+ if (c.getStatus().startsWith("Created")) {
+ h.setStatus(HealthTestStatus.RED);
+ h.setMessageCode("Container never started");
+ return h;
+ }
+ if (c.getStatus().startsWith("Restarting")) {
+ h.setStatus(HealthTestStatus.RED);
+ h.setMessageCode("Container restarting");
+ return h;
+ }
+ if (i.getManagerPortNumber() > 0) {
+ System.out.println("DOCKER: test" + i.getDockerName() + "HERE");
+ return console(instanceName).testContainer(i.getDockerName());
+ }
+ h.setStatus(HealthTestStatus.GREEN);
+ return h;
+ }
+
+ public void suspend(String instanceName) {
+ DockerServiceInstance i = findInstance(instanceName);
+ console(instanceName).suspendContainer(i.getDockerName());
+ }
+
+ public void resume(String instanceName) {
+ DockerServiceInstance i = findInstance(instanceName);
+ console(instanceName).resumeContainer(i.getDockerName());
+ }
+
+ public void pushManagerConfiguration(String instanceName) {
+ DockerServiceInstance i = findInstance(instanceName);
+ DcaeDockerHostManagerConsole console = console(instanceName);
+ EObject config = o.managerConfiguration(instanceName);
+ System.out.println("DDDDD " + ManagementServer.ecore2json(config, 1000, null, true).toString(2));
+ EList<DcaeStream> l1 = new BasicEList<DcaeStream>();
+ l1.addAll(EcoreUtil.copyAll(i.getInputStreams()));
+ EList<DcaeStream> l2 = new BasicEList<DcaeStream>();
+ l2.addAll(EcoreUtil.copyAll(i.getOutputStreams()));
+ console.updateContainerConfiguration(i.getDockerName(), config, decrypt(l1), decrypt(l2));
+ }
+
+ private EList<DcaeStream> decrypt(EList<DcaeStream> l) {
+ for (DcaeStream s : l) {
+ if (s instanceof DmaapStream) {
+ DmaapStream s1 = (DmaapStream) s;
+ String pw = s1.getDmaapPassword();
+ if (pw != null && pw.startsWith("rsa:")) {
+ try {
+ s1.setDmaapPassword(JavaHttpClient.decryptPassword(pw));
+ } catch (Exception e) {
+ System.err.println("ZZZZZ: bad pw: " + ManagementServer.object2ref(s));
+ s1.setDmaapPassword("decryption error");
+ }
+ } else {
+ System.err.println("ZZZZZ: unencrypted pw: " + ManagementServer.object2ref(s));
+ }
+ continue;
+ }
+ System.err.println("ZZZZZ: unknown type: " + s.getClass().getName());
+ }
+ return l;
+ }
+
+ public void pollManagerConfiguration(String instanceName) {
+
+ // TODO IMPLEMENT
+ throw new UnsupportedOperationException();
+ }
+
+ public org.eclipse.emf.ecore.EObject managerConfiguration(String instanceName) {
+ // TODO IMPLEMENT
+ throw new UnsupportedOperationException();
+ }
+
+ public JSONObject managerOperation(String instanceName, String operation, JSONObject parameters) {
+ // TODO IMPLEMENT
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateConfigurationFromPolicy(String instanceName) {
+
+ // TODO IMPLEMENT
+ throw new UnsupportedOperationException();
+ }
+
+ public void runHealthTests() {
+ for (DockerServiceInstance i : o.getInstances()) {
+ HealthTestResponse s = null;
+ try {
+ if (i.getStatus() == DeploymentStatus.DEPLOYED) {
+ s = test(i.getName());
+ } else {
+ s = ServiceFactory.eINSTANCE.createHealthTestResponse();
+ s.setMessageCode("Not deployed");
+ s.setStatus(HealthTestStatus.YELLOW);
+ }
+ } catch (Exception e) {
+ s = ServiceFactory.eINSTANCE.createHealthTestResponse();
+ s.setMessageCode("Unable to determine health: " + e);
+ s.setStatus(HealthTestStatus.RED);
+ }
+ i.setHealthTestStatus(s.getStatus());
+ i.setHealthTestMessageCode(s.getMessageCode());
+ MetricStore store = controller.getServer().metrics.getStore(i);
+ Date now = new Date();
+ String path = "/lastHealthTest";
+ store.addLongValue(path, now, now.getTime(), "DateMetricAttribute", false);
+ }
+ }
+
+ public void start() {
+
+ Thread t = new Thread("docker service: " + o.getName()) {
+ @Override
+ public void run() {
+ while (true) {
+ try {
+ if (!controller.getServer().isSlave) {
+ updateDeploymentStatus();
+ }
+ Thread.sleep(60000); // sleep 60 seconds
+ } catch (Exception e) {
+ ManagementServerUtils.printStackTrace(e);
+ logger.fatal("vm service: " + o.getName() + " : " + e);
+ try {
+ Thread.sleep(30000);
+ } catch (InterruptedException e1) {
+ }
+ }
+ }
+ }
+
+ };
+ t.start();
+ }
+
+ public void updateDeploymentStatus() {
+ for (DockerServiceInstance instance : o.getInstances()) {
+ instance.setDockerName(dockerName(instance));
+ DockerContainer c = findContainer(instance);
+ if (c != null) {
+ if (c.getStatus() != null && c.getStatus().startsWith("Up")) {
+ instance.setStatus(DeploymentStatus.DEPLOYED);
+ } else {
+ instance.setStatus(DeploymentStatus.DEPLOYED_PARTIALLY);
+ }
+ } else {
+ instance.setStatus(DeploymentStatus.UNDEPLOYED);
+ }
+ }
+ }
+
+ private DockerContainer findContainer(DockerServiceInstance instance) {
+ if (instance.getHostService() == null) {
+ return null;
+ }
+ for (DockerContainer c : instance.getHostService().getDockerHost().getContainers()) {
+ if (instance.getDockerName() != null && instance.getDockerName().equals(c.getName())) {
+ return c;
+ }
+ }
+ return null;
+ }
+
+ protected EObject convertToManagerConfiguration(DockerServiceInstance i) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
diff --git a/dcae-controller-service-docker/dcae-controller-service-docker-adaptor/src/main/java/org/openecomp/dcae/controller/service/servers/dockermanager/DcaeDockerManagerProvider.java b/dcae-controller-service-docker/dcae-controller-service-docker-adaptor/src/main/java/org/openecomp/dcae/controller/service/servers/dockermanager/DcaeDockerManagerProvider.java
index 13173ac..a5f1aa2 100644
--- a/dcae-controller-service-docker/dcae-controller-service-docker-adaptor/src/main/java/org/openecomp/dcae/controller/service/servers/dockermanager/DcaeDockerManagerProvider.java
+++ b/dcae-controller-service-docker/dcae-controller-service-docker-adaptor/src/main/java/org/openecomp/dcae/controller/service/servers/dockermanager/DcaeDockerManagerProvider.java
@@ -18,17 +18,13 @@
* limitations under the License.
* ============LICENSE_END============================================
*/
-
-package org.openecomp.dcae.controller.service.servers.dockermanager;
-import java.io.OutputStreamWriter;
-import java.util.Date;
+package org.openecomp.dcae.controller.service.servers.dockermanager;
import org.apache.log4j.Logger;
import org.eclipse.emf.common.util.EList;
import org.json.JSONArray;
import org.json.JSONObject;
-
import org.openecomp.dcae.controller.core.service.HealthTestResponse;
import org.openecomp.dcae.controller.core.service.HealthTestStatus;
import org.openecomp.dcae.controller.core.service.ServiceFactory;
@@ -46,120 +42,127 @@ import org.openecomp.ncomp.sirius.manager.logging.NcompLogger;
import org.openecomp.ncomp.utils.ShellCmd;
import org.openecomp.ncomp.webservice.utils.FileUtils;
+import java.io.OutputStreamWriter;
+import java.util.Date;
+
public class DcaeDockerManagerProvider extends BasicAdaptorProvider {
- private static final Logger logger = Logger.getLogger(DcaeDockerManagerProvider.class);
- private static final NcompLogger ecomplogger = NcompLogger.getNcompLogger();
- DockerManager o;
- private boolean suspended;
-
- public DcaeDockerManagerProvider(ISiriusServer controller, DockerManager o) {
- super(controller, o);
- this.o = o;
- }
-
- public HealthTestResponse test() {
- HealthTestResponse res = ServiceFactory.eINSTANCE.createHealthTestResponse();
- res.setStatus(HealthTestStatus.GREEN);
- return res;
- }
-
- public void suspend() {
- suspended = true;
- }
-
- public void resume() {
- suspended = false;
- }
-
- public java.lang.String publicKey() {
- throw new UnsupportedOperationException();
- }
-
- // US618656
- public void configurationChanged() {
- updateDMaapConfig();
- }
-
- // US618665
- private void updateDMaapConfig() {
- JSONArray a = new JSONArray();
- for (DcaeStream s : o.getInputStreams()) {
- JSONObject json = ManagementServer.ecore2json(s, 100, null, true);
- json.put("dmaapStreamId", s.getName());
- a.put(json);
- }
- for (DcaeStream s : o.getOutputStreams()) {
- JSONObject json = ManagementServer.ecore2json(s, 100, null, true);
- json.put("dmaapStreamId", s.getName());
- a.put(json);
- }
- write2file(a, "/tmp/dmaap.conf2");
- write2file(a, "/etc/dcae/dmaap.conf");
-
- }
-
- private void write2file(JSONArray a, String fileName) {
- try {
- OutputStreamWriter w = FileUtils.filename2writer(fileName);
- w.write(a.toString(2));
- w.close();
- } catch (Exception e) {
- logger.warn("Unable to write file: " + fileName);
- ManagementServerUtils.printStackTrace(e);
- }
- }
-
- public void updateStreams(EList<DcaeStream> inputStreams, EList<DcaeStream> outputStreams) {
- o.getInputStreams().clear();
- o.getInputStreams().addAll(inputStreams);
- o.getOutputStreams().clear();
- o.getOutputStreams().addAll(outputStreams);
- }
-
- public void scheduleCronjob(final String cmd, final long frequency) {
- ecomplogger.setOperation(DockerManager2OperationEnum.DOCKER_MANAGER_START_NEW_CRON);
- ecomplogger.newRequestId();
- ecomplogger.setInstanceId(controller, o);
- ecomplogger.recordAuditEventStart();
- EcompMessageEnum msg1 = DockerManager2MessageEnum.DOCKER_MANAGER_START_NEW_CRON;
- ;
- ecomplogger.recordAuditEventEnd(StatusCodeEnum.COMPLETE, msg1, cmd, Long.toString(frequency));
-
- Thread t = new Thread("crontab: " + cmd) {
- @Override
- public void run() {
- while (true) {
- try {
- Date now = new Date();
- long wait = frequency - (now.getTime() % frequency);
- Thread.sleep(wait);
- if (suspended)
- continue;
- try {
- ecomplogger.setOperation(DockerManager2OperationEnum.DOCKER_MANAGER_START_CRON_RUN);
- ecomplogger.newRequestId();
- ecomplogger.setInstanceId(controller, o);
- ecomplogger.recordAuditEventStart();
- ShellCmd c = new ShellCmd(cmd);
- c.result(frequency);
- ecomplogger.recordAuditEventEnd();
- } catch (Exception e) {
- e.printStackTrace();
- EcompMessageEnum msg = DockerManager2MessageEnum.DOCKER_MANAGER_CRON_FAILURE;
- ecomplogger.recordAuditEventEnd(StatusCodeEnum.ERROR, msg, cmd, e.toString());
- }
- } catch (Exception e) {
- ManagementServerUtils.printStackTrace(e);
- logger.fatal("crontab: " + cmd + " " + e);
- try {
- Thread.sleep(30000);
- } catch (InterruptedException e1) {
- }
- }
- }
- };
- };
- t.start();
- }
+ private static final Logger logger = Logger.getLogger(DcaeDockerManagerProvider.class);
+ private static final NcompLogger ecomplogger = NcompLogger.getNcompLogger();
+ DockerManager o;
+ private boolean suspended;
+
+ public DcaeDockerManagerProvider(ISiriusServer controller, DockerManager o) {
+ super(controller, o);
+ this.o = o;
+ }
+
+ public HealthTestResponse test() {
+ HealthTestResponse res = ServiceFactory.eINSTANCE.createHealthTestResponse();
+ res.setStatus(HealthTestStatus.GREEN);
+ return res;
+ }
+
+ public void suspend() {
+ suspended = true;
+ }
+
+ public void resume() {
+ suspended = false;
+ }
+
+ public java.lang.String publicKey() {
+ throw new UnsupportedOperationException();
+ }
+
+ // US618656
+ public void configurationChanged() {
+ updateDMaapConfig();
+ }
+
+ // US618665
+ private void updateDMaapConfig() {
+ JSONArray a = new JSONArray();
+ for (DcaeStream s : o.getInputStreams()) {
+ JSONObject json = ManagementServer.ecore2json(s, 100, null, true);
+ json.put("dmaapStreamId", s.getName());
+ a.put(json);
+ }
+ for (DcaeStream s : o.getOutputStreams()) {
+ JSONObject json = ManagementServer.ecore2json(s, 100, null, true);
+ json.put("dmaapStreamId", s.getName());
+ a.put(json);
+ }
+ write2file(a, "/tmp/dmaap.conf2");
+ write2file(a, "/etc/dcae/dmaap.conf");
+
+ }
+
+ private void write2file(JSONArray a, String fileName) {
+ try {
+ OutputStreamWriter w = FileUtils.filename2writer(fileName);
+ w.write(a.toString(2));
+ w.close();
+ } catch (Exception e) {
+ logger.warn("Unable to write file: " + fileName);
+ ManagementServerUtils.printStackTrace(e);
+ }
+ }
+
+ public void updateStreams(EList<DcaeStream> inputStreams, EList<DcaeStream> outputStreams) {
+ o.getInputStreams().clear();
+ o.getInputStreams().addAll(inputStreams);
+ o.getOutputStreams().clear();
+ o.getOutputStreams().addAll(outputStreams);
+ }
+
+ public void scheduleCronjob(final String cmd, final long frequency) {
+ ecomplogger.setOperation(DockerManager2OperationEnum.DOCKER_MANAGER_START_NEW_CRON);
+ ecomplogger.newRequestId();
+ ecomplogger.setInstanceId(controller, o);
+ ecomplogger.recordAuditEventStart();
+ EcompMessageEnum msg1 = DockerManager2MessageEnum.DOCKER_MANAGER_START_NEW_CRON;
+ ;
+ ecomplogger.recordAuditEventEnd(StatusCodeEnum.COMPLETE, msg1, cmd, Long.toString(frequency));
+
+ Thread t = new Thread("crontab: " + cmd) {
+ @Override
+ public void run() {
+ while (true) {
+ try {
+ Date now = new Date();
+ long wait = frequency - (now.getTime() % frequency);
+ Thread.sleep(wait);
+ if (suspended) {
+ continue;
+ }
+ try {
+ ecomplogger.setOperation(DockerManager2OperationEnum.DOCKER_MANAGER_START_CRON_RUN);
+ ecomplogger.newRequestId();
+ ecomplogger.setInstanceId(controller, o);
+ ecomplogger.recordAuditEventStart();
+ ShellCmd c = new ShellCmd(cmd);
+ c.result(frequency);
+ ecomplogger.recordAuditEventEnd();
+ } catch (Exception e) {
+ logger.error("exception occured ", e);
+ //e.printStackTrace();
+ EcompMessageEnum msg = DockerManager2MessageEnum.DOCKER_MANAGER_CRON_FAILURE;
+ ecomplogger.recordAuditEventEnd(StatusCodeEnum.ERROR, msg, cmd, e.toString());
+ }
+ } catch (Exception e) {
+ ManagementServerUtils.printStackTrace(e);
+ logger.fatal("crontab: " + cmd + " " + e);
+ try {
+ Thread.sleep(30000);
+ } catch (InterruptedException e1) {
+ }
+ }
+ }
+ }
+
+ ;
+ };
+ t.start();
+ }
}
diff --git a/dcae-controller-service-vm/dcae-controller-service-vm-adaptor/src/main/java/org/openecomp/dcae/controller/service/servers/vm/DcaeVirtualMachineServiceProvider.java b/dcae-controller-service-vm/dcae-controller-service-vm-adaptor/src/main/java/org/openecomp/dcae/controller/service/servers/vm/DcaeVirtualMachineServiceProvider.java
index 2f9e39b..ff91c40 100644
--- a/dcae-controller-service-vm/dcae-controller-service-vm-adaptor/src/main/java/org/openecomp/dcae/controller/service/servers/vm/DcaeVirtualMachineServiceProvider.java
+++ b/dcae-controller-service-vm/dcae-controller-service-vm-adaptor/src/main/java/org/openecomp/dcae/controller/service/servers/vm/DcaeVirtualMachineServiceProvider.java
@@ -18,18 +18,9 @@
* limitations under the License.
* ============LICENSE_END============================================
*/
-
-package org.openecomp.dcae.controller.service.servers.vm;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+package org.openecomp.dcae.controller.service.servers.vm;
import org.apache.log4j.Logger;
import org.eclipse.emf.common.util.BasicEList;
@@ -39,8 +30,6 @@ import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jetty.util.B64Code;
import org.json.JSONObject;
-import org.yaml.snakeyaml.Yaml;
-
import org.openecomp.dcae.controller.core.server.DcaeBasicServer;
import org.openecomp.dcae.controller.core.server.DcaeBasicServerNetwork;
import org.openecomp.dcae.controller.core.service.DcaeLocation;
@@ -75,7 +64,6 @@ import org.openecomp.ncomp.sirius.manager.AbstractClient;
import org.openecomp.ncomp.sirius.manager.BasicAdaptorProvider;
import org.openecomp.ncomp.sirius.manager.ISiriusServer;
import org.openecomp.ncomp.sirius.manager.JavaHttpClient;
-import org.openecomp.ncomp.sirius.manager.Jetty8Client;
import org.openecomp.ncomp.sirius.manager.ManagementServer;
import org.openecomp.ncomp.sirius.manager.ManagementServerUtils;
import org.openecomp.ncomp.sirius.manager.Subject;
@@ -86,808 +74,850 @@ import org.openecomp.ncomp.sirius.manager.server.ResponseStatus;
import org.openecomp.ncomp.sirius.manager.server.ServerFactory;
import org.openecomp.ncomp.utils.CryptoUtils;
import org.openecomp.ncomp.utils.StringUtil;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
public class DcaeVirtualMachineServiceProvider extends BasicAdaptorProvider {
- private static final Logger logger = Logger.getLogger(DcaeVirtualMachineServiceProvider.class);
- VirtualMachineService o;
- private String privateKey = CryptoUtils.getKey("config/server.private");
-
- public DcaeVirtualMachineServiceProvider(ISiriusServer controller, VirtualMachineService o) {
- super(controller, o);
- this.o = o;
- }
-
- public void deploy(String instanceName, String containerPath) {
- System.err.println("XXX deploy server: " + instanceName + " " + containerPath);
- Response res = ServerFactory.eINSTANCE.createResponse();
- VirtualMachineServiceInstance i = findInstance(instanceName);
- if (containerPath != null && !containerPath.equals("")) {
- Subject s = controller.getServer().find(containerPath);
- if (i == null) {
- throw new RuntimeException("Unable to find instance: " + instanceName);
- }
- if (s == null || s.o == null) {
- throw new RuntimeException("Unable to find container object: " + containerPath);
- }
- if (!(s.o instanceof DcaeLocation))
- throw new RuntimeException("Unable to deploy to this non location container: " + containerPath);
- i.setLocation((DcaeLocation) s.o);
- }
- DcaeLocation location = i.getLocation();
- if (location == null)
- throw new RuntimeException("Unable to deploy no location specified: " + ManagementServer.object2ref(i));
- String networkId = null;
- String networkName = location.getOpenstackProject().getPrivateNetwork();
- String subnetId = null;
- for (Network network : location.getOpenstackProject().getNetworks()) {
- if (network.getName().equals(networkName)) {
- networkId = network.getId();
- subnetId = network.getSubnets().get(0);
- }
- }
- if (networkId == null) {
- throw new RuntimeException("Unable to find network: " + networkName);
- }
- HashMap<DcaeBasicServer, Port> portMap = new LinkedHashMap<DcaeBasicServer, Port>();
- OpenStackLocation loc = (OpenStackLocation) location.getOpenstackProject().eContainer();
- for (int j = 0; j < i.getNumberOfServers(); j++) {
- DcaeBasicServer server = i.getServers().get(j);
- if (i.getVmType().isNeedPublicIp() && server.getNetworks().get(0).getIp() == null) {
- throw new RuntimeException("Deployment issue: server not assigned IP: " + server.getName());
- }
- for (Port port : location.getOpenstackProject().getPorts()) {
- if (port.getName().equals(server.getName())) {
- portMap.put(server, port);
- }
- }
- if (portMap.get(server) == null) {
- CreatePortRequest portReq = NeutronFactory.eINSTANCE.createCreatePortRequest();
- portReq.setName(server.getName());
- portReq.setProjectName(location.getOpenstackProject().getName());
- portReq.setNetwork_id(networkId);
- // if assigned ip but no public network, assume IP is on private and available
- String ip2 = server.getNetworks().get(0).getIp();
- if (ip2 != null && ! loc.isSupportsFloatingIps()) {
- FixedIp fip = NeutronFactory.eINSTANCE.createFixedIp();
- fip.setIp_address(ip2);
- fip.setSubnet_id(subnetId);
- portReq.getFixed_ips().add(fip );
- }
- // create port in Openstack
- Port port = loc.createPort(portReq);
- portMap.put(server, port);
- }
- }
- for (int j = 0; j < i.getNumberOfServers(); j++) {
- OpenstackRequestNewServer r = ComputeFactory.eINSTANCE.createOpenstackRequestNewServer();
- r.setVmType(EcoreUtil.copy(i.getVmType()));
- r.setName(vmName(i, j));
- r.setProjectName(location.getOpenstackProject().getName());
- if (i.getAvailabilityZone() != null)
- r.setHypervisor(i.getAvailabilityZone());
- if (i.getUsers().size() > 0) {
- r.setUser(i.getUsers().get(0).getName());
- }
- r.setUser_data(B64Code.encode(userdata(i, j, portMap)));
- DcaeBasicServer server = i.getServers().get(j);
- if (o.getName().equals("vm-controller")) {
- if (server.getServer() != null) {
- // Existing Controller VM. ignore it
- continue;
- }
- }
- createServerHook(o,i,server);
- boolean floatingIpDone = false;
- String ip2 = server.getNetworks().get(0).getIp();
- for (NeutronFloatingIp fip : location.getOpenstackProject().getFloatingips()) {
- if (ip2 != null && ip2.equals(fip.getFloating_ip_address())) {
- if (fip.getFixed_ip_address() != null) {
- floatingIpDone = true;
- }
- }
- }
- if (!floatingIpDone && loc.isSupportsFloatingIps())
- r.setFloatingIp(ip2);
- else
- r.getVmType().setNeedPublicIp(false);
- r.getPorts().add(portMap.get(server).getId());
- if (! loc.isSupportsFloatingIps() && location.getOpenstackProject().getPublicNetwork() != null) {
- // find external network.
- String networkId2 = null;
- String networkName2 = location.getOpenstackProject().getPublicNetwork();
- if (networkName2.matches("........-....-....-....-............")) {
- networkId2 = networkName2;
- }
- else {
- for (Network network : location.getOpenstackProject().getNetworks()) {
- if (network.getName().equals(networkName)) {
- networkId2 = network.getId();
- }
- }
- }
- if (networkId2 == null) {
- throw new RuntimeException("Unable to find public network: " + networkName2);
- }
- r.getNetworks().add(networkId2);
- }
- if (i.getOpenstackFlavor() != null)
- r.getVmType().setFlavorName(i.getOpenstackFlavor());
- System.out.println("loc.isSupportsFloatingIps(): " + loc.isSupportsFloatingIps());
- System.out.println("location.getOpenstackProject().getPublicNetwork(): " + location.getOpenstackProject().getPublicNetwork());
- System.out.println(ManagementServer.ecore2json(r, 100, null, true).toString(2));
- loc.createServer(r);
- logger.info("created server: " + r.getName());
- }
- controller.getServer().save();
- long toolate = System.currentTimeMillis() + i.getDeploymentTimeoutMinutes() * 60 * 1000;
- while (i.getStatus() != DeploymentStatus.DEPLOYED) {
- if (System.currentTimeMillis() > toolate) {
- throw new RuntimeException("Deployment timeout: VM did not show up");
- }
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ie) {
- }
- }
- if (i.getManagerPortNumber() > 0) {
- while (System.currentTimeMillis() < toolate) {
- try {
- o.pushManagerConfiguration(instanceName);
- break;
- } catch (Exception e) {
- try {
- Thread.sleep(10000);
- } catch (InterruptedException e1) {
- throw new RuntimeException("Deployment timeout: Deployment interrupted");
- }
- }
- if (System.currentTimeMillis() >= toolate)
- throw new RuntimeException("Unable to configure VM");
- }
- }
- res.setStatus(ResponseStatus.OK);
- // return res;
- }
-
- protected void createServerHook(VirtualMachineService o, VirtualMachineServiceInstance i, DcaeBasicServer server) {
-
- }
-
- // used for testing only
- static String userdataStatic(VirtualMachineServiceInstance i, int j, HashMap<DcaeBasicServer, Port> portMap) {
- DcaeVirtualMachineServiceProvider pp = new DcaeVirtualMachineServiceProvider(null, null);
- return pp.userdata(i, j, portMap);
- }
-
- @SuppressWarnings("unchecked")
- protected String userdata(VirtualMachineServiceInstance i, int j, HashMap<DcaeBasicServer, Port> portMap) {
- StringBuffer buf = new StringBuffer();
- HashMap<String, Object> configMap = new HashMap<String, Object>();
- buf.append(userdataInitial());
- String resourceName = "instances/" + i.getService().getName() + "/" + i.getName() + ".yaml";
- String x = null;
- try {
- x = getTemplate(resourceName);
- } catch (Exception e1) {
- buf.append("#### No special configuration resource: " + resourceName);
- buf.append("\n");
- }
- if (x != null) {
- Yaml yaml = new Yaml();
- configMap = (HashMap<String, Object>) yaml.load(x);
- buf.append("#### Using special configuration resource: " + resourceName);
- buf.append("\n");
- }
- DcaeBasicServer s = i.getServers().get(j);
- if (configMap.containsKey("configuration-files"))
- buf.append(userdataConfig(configMap.get("configuration-files"), s));
- if (configMap.containsKey("init-script"))
- buf.append(configMap.get("init-script")).append("\n");
- buf.append(userdataHosts(s, portMap));
- buf.append(userdataCertificate(s));
- buf.append(userdataFromFile("CLOUDINIT",i, s)).append("\n");
- for (User u : i.getAdminUsers()) {
- buf.append(userdataSshKey(i.getAdminId(), u.getPublicKey()));
- }
- buf.append(userdataSteps(i, s, portMap)).append("\n");
- for (String id : i.getApplicationIds()) {
- buf.append(userdataSshSetup(id));
- for (User u : i.getUsers()) {
- buf.append(userdataSshKey(id, u.getPublicKey()));
- }
- }
- try {
- buf.append(getTemplate(i.getService().getName() + ".userdata"));
- } catch (Exception e) {
- buf.append("#no final script: " + i.getService().getName() + ".userdata").append("\n");
- }
- if (configMap.containsKey("final-script"))
- buf.append(configMap.get("final-script")).append("\n");
- buf.append(userdataFinal(i,s));
- System.err.println("USER DATA: " + ManagementServer.object2ref(i) + "\n" + buf);
- return buf.toString();
- }
-
- private String userdataSteps(VirtualMachineServiceInstance i, DcaeBasicServer s,
- HashMap<DcaeBasicServer, Port> portMap) {
- StringBuffer buf = new StringBuffer();
- for (InstallationStep step : i.getSteps()) {
- buf.append("######### ").append(step.getName()).append("\n");
- String str = null, str1 = null;
- try {
- str = getTemplate(step.eClass().getName() + ".userdata");
- JSONObject json = ManagementServer.ecore2json(step, 100, null, true);
- str1 = StringUtil.expandUsingJson(str, json, "%");
- buf.append(str1).append("\n");
- } catch (Exception e) {
- System.err.println("userdataSteps error: str=" + str + " str1=" + str1 + " e=" + e);
- e.printStackTrace();
- }
- }
- return buf.toString();
- }
-
- protected String userdataConfig(Object o, DcaeBasicServer s) {
- StringBuffer buf = new StringBuffer();
- @SuppressWarnings("unchecked")
- HashMap<String, HashMap<String, String>> m1 = (HashMap<String, HashMap<String, String>>) o;
- for (String k : m1.keySet()) {
- HashMap<String, String> m2 = m1.get(k);
- buf.append("## Adding configuration file: ").append(k).append("\n");
- String decode = "cat";
- if (m2.containsKey("encoding") && "base64".equals(m2.get("encoding"))) {
- decode = "base64 --decode";
- }
- buf.append("cat | ").append(decode).append(" > ").append(m2.get("destination")).append(" << EOF_CONFIG\n");
- String content = m2.get("content");
- if (m2.containsKey("encrypted-password")) {
- String pw = CryptoUtils.decryptPrivate(privateKey, m2.get("encrypted-password"));
- content = CryptoUtils.decrypt(pw, content);
- }
- JSONObject json = new JSONObject();
- String pw = JavaHttpClient.decryptPassword(s.getCertificatePassword());
- json.put("certPassword", pw == null ? "No Certificate" : pw);
- if (content.contains("%{")) {
- System.err.print("CONTENT" + content + " " + json);
- }
- content = StringUtil.expandUsingJson(content, json, "%");
- if (content.contains("%{")) {
- System.err.print("CONTENT 2" + content);
- }
- content = decryptString(content);
- buf.append(content).append("\n");
- buf.append("EOF_CONFIG").append("\n");
- if (m2.containsKey("owner"))
- buf.append("chown ").append(m2.get("owner")).append(" ").append(m2.get("destination")).append("\n");
- }
- return buf.toString();
- }
-
- private String decryptString(String content) {
- Pattern p = Pattern.compile("(rsa:[A-Za-z0-9+/]+ *[A-Za-z0-9+/]+ *[A-Za-z0-9+/]+=*)");
- Matcher m = p.matcher(content);
- StringBuffer s = new StringBuffer();
- while (m.find()) {
- String k = m.group(1);
- m.appendReplacement(s, JavaHttpClient.decryptPassword(k));
- }
- m.appendTail(s);
- return s.toString();
- }
-
- protected String userdataSshSetup(String id) {
- StringBuffer buf = new StringBuffer();
- if (id == null) {
- buf.append("### userdataSshSetup null ID: ").append("\n");
- return buf.toString();
- }
- buf.append("mkdir /home/ID/.ssh\n".replace("ID", id));
- buf.append("chmod og-rwx /home/ID/.ssh\n".replace("ID", id));
- buf.append("chown -R ID:ID /home/ID/.ssh\n".replace("ID", id));
- buf.append("touch /home/ID/.ssh/authorized_keys\n".replace("ID", id));
- buf.append("chmod og-rwx /home/ID/.ssh/authorized_keys\n".replace("ID", id));
- buf.append("chown -R ID:ID /home/ID/.ssh/authorized_keys\n".replace("ID", id));
- return buf.toString();
- }
-
- protected String userdataSshKey(String id, String publicKey) {
- StringBuffer buf = new StringBuffer();
- if (id == null) {
- return "";
- }
- if (publicKey == null) {
- buf.append("### null key: ").append(id).append("\n");
- return buf.toString();
- }
- buf.append("echo ").append(publicKey.trim()).append(" >> /home/").append(id).append("/.ssh/authorized_keys\n");
- return buf.toString();
- }
-
- protected Object userdataCertificate(DcaeBasicServer s) {
- StringBuffer buf = new StringBuffer();
- byte[] cert;
- try {
- cert = getTemplateBinary(s.getName() + ".pkcs12");
- // buf.append("### check sum: " +
- // MD5Checksum.createChecksum(cert)).append("\n");
- buf.append("cat > /tmp/certificate.pkcs12.b64code << EOF_CERT").append("\n");
- buf.append(B64Code.encode(cert)).append("\n");
- buf.append("EOF_CERT").append("\n");
- } catch (Exception e) {
- // TODO Auto-generated catch block
- buf.append("## UNABLE TO FIND CERTIFICATE FOR: " + s.getName()).append("\n");
- }
- return buf.toString();
- }
-
- protected Object userdataCertificatePassword(DcaeBasicServer s) {
- StringBuffer buf = new StringBuffer();
- buf.append("echo ").append(JavaHttpClient.decryptPassword(s.getCertificatePassword()))
- .append(" > /tmp/.password\n");
- return buf.toString();
- }
-
- protected String userdataHosts(DcaeBasicServer s, HashMap<DcaeBasicServer, Port> portMap) {
- StringBuffer buf = new StringBuffer();
- buf.append("cat >> /etc/hosts << HOSTS_EOF").append("\n");
- for (DcaeBasicServer s1 : portMap.keySet()) {
- for (FixedIp x : portMap.get(s1).getFixed_ips()) {
- buf.append(x.getIp_address() + " " + dnsName(s1) + " " + s1.getName()).append("\n");
- }
- }
- buf.append("HOSTS_EOF").append("\n");
- buf.append("echo ").append(s.getName()).append(" > /etc/hostname\n");
- int index = 0;
- for (DcaeBasicServer s1 : portMap.keySet()) {
- for (FixedIp x : portMap.get(s1).getFixed_ips()) {
- buf.append("IP" + index + "=").append(x.getIp_address()).append("\n");
- }
- index++;
- }
- return buf.toString();
- }
-
- protected static String getTemplate(String resource) throws IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- byte[] data = new byte[65536];
- InputStream is = DcaeVirtualMachineServiceProvider.class.getClassLoader().getResourceAsStream(resource);
- if (is == null) {
- throw new RuntimeException("Unable to find resource: " + resource);
- }
- int i;
- try {
- while ((i = is.read(data)) > 0) {
- baos.write(data, 0, i);
- }
- } catch (Exception e) {
- ManagementServerUtils.printStackTrace(e);
- } finally {
- if (is != null)
- is.close();
- }
- return (new String(baos.toByteArray()));
- }
-
- static byte[] getTemplateBinary(String rnm) throws IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- byte[] data = new byte[65536];
- InputStream is = DcaeVirtualMachineServiceProvider.class.getClassLoader().getResourceAsStream(rnm);
- int i;
- try {
- while ((i = is.read(data)) > 0) {
- baos.write(data, 0, i);
- }
- } catch (Exception e) {
- ManagementServerUtils.printStackTrace(e);
- } finally {
- if (is != null)
- is.close();
- }
- return baos.toByteArray();
- }
-
- protected Object userdataFromFile(String name, VirtualMachineServiceInstance i, DcaeBasicServer s2) {
- try {
- String s = getTemplate(name + ".userdata");
- JSONObject json = new JSONObject();
- DcaeBasicServerNetwork n = s2.getNetworks().get(0);
- String dns = n.getDnsName();
- json.put("dnsDomain", dns.substring(dns.indexOf(".") + 1));
- json.put("admin", i.getIedsAdmin());
- return StringUtil.expandUsingJson(s, json, "%");
- } catch (Exception e) {
- return "#error " + name + ".userdata: " + e;
- }
- }
-
-
- protected String userdataInitial() {
- StringBuffer buf = new StringBuffer();
- buf.append("#!/bin/bash").append("\n");
- buf.append("cat > /tmp/dcae_install.sh << EOF_DCAE_INSTALL").append("\n");
- buf.append("#!/bin/bash").append("\n");
- buf.append("set -x").append("\n");
- buf.append("cd /tmp").append("\n");
- return buf.toString();
- }
-
- protected String userdataFinal(VirtualMachineServiceInstance i, DcaeBasicServer s) {
- StringBuffer buf = new StringBuffer();
- buf.append("EOF_DCAE_INSTALL").append("\n");
- buf.append(userdataCertificatePassword(s));
- buf.append("bash /tmp/dcae_install.sh 2>&1 | tee /tmp/dcae_install.log").append("\n");
- return buf.toString();
- }
-
- public void undeploy(java.lang.String instanceName) {
- if (o.getName().equals("vm-controller"))
- throw new RuntimeException("Cannot undeploy vm-controller, please use Horizon");
- VirtualMachineServiceInstance i = findInstance(instanceName);
- for (int j = 0; j < i.getNumberOfServers(); j++) {
- // System.out.println("HHHH: " + i.getServers().get(j).getName());
- if (i.getLocation() == null)
- continue;
- OpenStackLocation loc = (OpenStackLocation) i.getLocation().getOpenstackProject().eContainer();
- String tname = i.getLocation().getOpenstackProject().getName();
- loc.deleteServer(tname, vmName(i, j));
- // System.out.println("HHHH deleted: " + vmName(i, j));
- }
- }
-
- protected static String dnsName(DcaeBasicServer s) {
- return s.getNetworks().get(0).getDnsName();
- }
-
- public void updateDeploymentStatus() {
+ private static final Logger logger = Logger.getLogger(DcaeVirtualMachineServiceProvider.class);
+ VirtualMachineService o;
+ private String privateKey = CryptoUtils.getKey("config/server.private");
+
+ public DcaeVirtualMachineServiceProvider(ISiriusServer controller, VirtualMachineService o) {
+ super(controller, o);
+ this.o = o;
+ }
+
+ public void deploy(String instanceName, String containerPath) {
+ System.err.println("XXX deploy server: " + instanceName + " " + containerPath);
+ Response res = ServerFactory.eINSTANCE.createResponse();
+ VirtualMachineServiceInstance i = findInstance(instanceName);
+ if (containerPath != null && !containerPath.equals("")) {
+ Subject s = controller.getServer().find(containerPath);
+ if (i == null) {
+ throw new RuntimeException("Unable to find instance: " + instanceName);
+ }
+ if (s == null || s.o == null) {
+ throw new RuntimeException("Unable to find container object: " + containerPath);
+ }
+ if (!(s.o instanceof DcaeLocation)) {
+ throw new RuntimeException("Unable to deploy to this non location container: " + containerPath);
+ }
+ i.setLocation((DcaeLocation) s.o);
+ }
+ DcaeLocation location = i.getLocation();
+ if (location == null) {
+ throw new RuntimeException("Unable to deploy no location specified: " + ManagementServer.object2ref(i));
+ }
+ String networkId = null;
+ String networkName = location.getOpenstackProject().getPrivateNetwork();
+ String subnetId = null;
+ for (Network network : location.getOpenstackProject().getNetworks()) {
+ if (network.getName().equals(networkName)) {
+ networkId = network.getId();
+ subnetId = network.getSubnets().get(0);
+ }
+ }
+ if (networkId == null) {
+ throw new RuntimeException("Unable to find network: " + networkName);
+ }
+ HashMap<DcaeBasicServer, Port> portMap = new LinkedHashMap<DcaeBasicServer, Port>();
+ OpenStackLocation loc = (OpenStackLocation) location.getOpenstackProject().eContainer();
+ for (int j = 0; j < i.getNumberOfServers(); j++) {
+ DcaeBasicServer server = i.getServers().get(j);
+ if (i.getVmType().isNeedPublicIp() && server.getNetworks().get(0).getIp() == null) {
+ throw new RuntimeException("Deployment issue: server not assigned IP: " + server.getName());
+ }
+ for (Port port : location.getOpenstackProject().getPorts()) {
+ if (port.getName().equals(server.getName())) {
+ portMap.put(server, port);
+ }
+ }
+ if (portMap.get(server) == null) {
+ CreatePortRequest portReq = NeutronFactory.eINSTANCE.createCreatePortRequest();
+ portReq.setName(server.getName());
+ portReq.setProjectName(location.getOpenstackProject().getName());
+ portReq.setNetwork_id(networkId);
+ // if assigned ip but no public network, assume IP is on private and available
+ String ip2 = server.getNetworks().get(0).getIp();
+ if (ip2 != null && !loc.isSupportsFloatingIps()) {
+ FixedIp fip = NeutronFactory.eINSTANCE.createFixedIp();
+ fip.setIp_address(ip2);
+ fip.setSubnet_id(subnetId);
+ portReq.getFixed_ips().add(fip);
+ }
+ // create port in Openstack
+ Port port = loc.createPort(portReq);
+ portMap.put(server, port);
+ }
+ }
+ for (int j = 0; j < i.getNumberOfServers(); j++) {
+ OpenstackRequestNewServer r = ComputeFactory.eINSTANCE.createOpenstackRequestNewServer();
+ r.setVmType(EcoreUtil.copy(i.getVmType()));
+ r.setName(vmName(i, j));
+ r.setProjectName(location.getOpenstackProject().getName());
+ if (i.getAvailabilityZone() != null) {
+ r.setHypervisor(i.getAvailabilityZone());
+ }
+ if (i.getUsers().size() > 0) {
+ r.setUser(i.getUsers().get(0).getName());
+ }
+ r.setUser_data(B64Code.encode(userdata(i, j, portMap)));
+ DcaeBasicServer server = i.getServers().get(j);
+ if (o.getName().equals("vm-controller")) {
+ if (server.getServer() != null) {
+ // Existing Controller VM. ignore it
+ continue;
+ }
+ }
+ createServerHook(o, i, server);
+ boolean floatingIpDone = false;
+ String ip2 = server.getNetworks().get(0).getIp();
+ for (NeutronFloatingIp fip : location.getOpenstackProject().getFloatingips()) {
+ if (ip2 != null && ip2.equals(fip.getFloating_ip_address())) {
+ if (fip.getFixed_ip_address() != null) {
+ floatingIpDone = true;
+ }
+ }
+ }
+ if (!floatingIpDone && loc.isSupportsFloatingIps()) {
+ r.setFloatingIp(ip2);
+ } else {
+ r.getVmType().setNeedPublicIp(false);
+ }
+ r.getPorts().add(portMap.get(server).getId());
+ if (!loc.isSupportsFloatingIps() && location.getOpenstackProject().getPublicNetwork() != null) {
+ // find external network.
+ String networkId2 = null;
+ String networkName2 = location.getOpenstackProject().getPublicNetwork();
+ if (networkName2.matches("........-....-....-....-............")) {
+ networkId2 = networkName2;
+ } else {
+ for (Network network : location.getOpenstackProject().getNetworks()) {
+ if (network.getName().equals(networkName)) {
+ networkId2 = network.getId();
+ }
+ }
+ }
+ if (networkId2 == null) {
+ throw new RuntimeException("Unable to find public network: " + networkName2);
+ }
+ r.getNetworks().add(networkId2);
+ }
+ if (i.getOpenstackFlavor() != null) {
+ r.getVmType().setFlavorName(i.getOpenstackFlavor());
+ }
+ System.out.println("loc.isSupportsFloatingIps(): " + loc.isSupportsFloatingIps());
+ System.out.println("location.getOpenstackProject().getPublicNetwork(): " + location.getOpenstackProject().getPublicNetwork());
+ System.out.println(ManagementServer.ecore2json(r, 100, null, true).toString(2));
+ loc.createServer(r);
+ logger.info("created server: " + r.getName());
+ }
+ controller.getServer().save();
+ long toolate = System.currentTimeMillis() + i.getDeploymentTimeoutMinutes() * 60 * 1000;
+ while (i.getStatus() != DeploymentStatus.DEPLOYED) {
+ if (System.currentTimeMillis() > toolate) {
+ throw new RuntimeException("Deployment timeout: VM did not show up");
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ie) {
+ }
+ }
+ if (i.getManagerPortNumber() > 0) {
+ while (System.currentTimeMillis() < toolate) {
+ try {
+ o.pushManagerConfiguration(instanceName);
+ break;
+ } catch (Exception e) {
+ try {
+ Thread.sleep(10000);
+ } catch (InterruptedException e1) {
+ throw new RuntimeException("Deployment timeout: Deployment interrupted");
+ }
+ }
+ if (System.currentTimeMillis() >= toolate) {
+ throw new RuntimeException("Unable to configure VM");
+ }
+ }
+ }
+ res.setStatus(ResponseStatus.OK);
+ // return res;
+ }
+
+ protected void createServerHook(VirtualMachineService o, VirtualMachineServiceInstance i, DcaeBasicServer server) {
+
+ }
+
+ // used for testing only
+ static String userdataStatic(VirtualMachineServiceInstance i, int j, HashMap<DcaeBasicServer, Port> portMap) {
+ DcaeVirtualMachineServiceProvider pp = new DcaeVirtualMachineServiceProvider(null, null);
+ return pp.userdata(i, j, portMap);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected String userdata(VirtualMachineServiceInstance i, int j, HashMap<DcaeBasicServer, Port> portMap) {
+ StringBuffer buf = new StringBuffer();
+ HashMap<String, Object> configMap = new HashMap<String, Object>();
+ buf.append(userdataInitial());
+ String resourceName = "instances/" + i.getService().getName() + "/" + i.getName() + ".yaml";
+ String x = null;
+ try {
+ x = getTemplate(resourceName);
+ } catch (Exception e1) {
+ buf.append("#### No special configuration resource: " + resourceName);
+ buf.append("\n");
+ }
+ if (x != null) {
+ Yaml yaml = new Yaml();
+ configMap = (HashMap<String, Object>) yaml.load(x);
+ buf.append("#### Using special configuration resource: " + resourceName);
+ buf.append("\n");
+ }
+ DcaeBasicServer s = i.getServers().get(j);
+ if (configMap.containsKey("configuration-files")) {
+ buf.append(userdataConfig(configMap.get("configuration-files"), s));
+ }
+ if (configMap.containsKey("init-script")) {
+ buf.append(configMap.get("init-script")).append("\n");
+ }
+ buf.append(userdataHosts(s, portMap));
+ buf.append(userdataCertificate(s));
+ buf.append(userdataFromFile("CLOUDINIT", i, s)).append("\n");
+ for (User u : i.getAdminUsers()) {
+ buf.append(userdataSshKey(i.getAdminId(), u.getPublicKey()));
+ }
+ buf.append(userdataSteps(i, s, portMap)).append("\n");
+ for (String id : i.getApplicationIds()) {
+ buf.append(userdataSshSetup(id));
+ for (User u : i.getUsers()) {
+ buf.append(userdataSshKey(id, u.getPublicKey()));
+ }
+ }
+ try {
+ buf.append(getTemplate(i.getService().getName() + ".userdata"));
+ } catch (Exception e) {
+ buf.append("#no final script: " + i.getService().getName() + ".userdata").append("\n");
+ }
+ if (configMap.containsKey("final-script")) {
+ buf.append(configMap.get("final-script")).append("\n");
+ }
+ buf.append(userdataFinal(i, s));
+ System.err.println("USER DATA: " + ManagementServer.object2ref(i) + "\n" + buf);
+ return buf.toString();
+ }
+
+ private String userdataSteps(VirtualMachineServiceInstance i, DcaeBasicServer s,
+ HashMap<DcaeBasicServer, Port> portMap) {
+ StringBuffer buf = new StringBuffer();
+ for (InstallationStep step : i.getSteps()) {
+ buf.append("######### ").append(step.getName()).append("\n");
+ String str = null, str1 = null;
+ try {
+ str = getTemplate(step.eClass().getName() + ".userdata");
+ JSONObject json = ManagementServer.ecore2json(step, 100, null, true);
+ str1 = StringUtil.expandUsingJson(str, json, "%");
+ buf.append(str1).append("\n");
+ } catch (Exception e) {
+ System.err.println("userdataSteps error: str=" + str + " str1=" + str1 + " e=" + e);
+ e.printStackTrace();
+ }
+ }
+ return buf.toString();
+ }
+
+ protected String userdataConfig(Object o, DcaeBasicServer s) {
+ StringBuffer buf = new StringBuffer();
+ @SuppressWarnings("unchecked")
+ HashMap<String, HashMap<String, String>> m1 = (HashMap<String, HashMap<String, String>>) o;
+ for (String k : m1.keySet()) {
+ HashMap<String, String> m2 = m1.get(k);
+ buf.append("## Adding configuration file: ").append(k).append("\n");
+ String decode = "cat";
+ if (m2.containsKey("encoding") && "base64".equals(m2.get("encoding"))) {
+ decode = "base64 --decode";
+ }
+ buf.append("cat | ").append(decode).append(" > ").append(m2.get("destination")).append(" << EOF_CONFIG\n");
+ String content = m2.get("content");
+ if (m2.containsKey("encrypted-password")) {
+ String pw = CryptoUtils.decryptPrivate(privateKey, m2.get("encrypted-password"));
+ content = CryptoUtils.decrypt(pw, content);
+ }
+ JSONObject json = new JSONObject();
+ String pw = JavaHttpClient.decryptPassword(s.getCertificatePassword());
+ json.put("certPassword", pw == null ? "No Certificate" : pw);
+ if (content.contains("%{")) {
+ System.err.print("CONTENT" + content + " " + json);
+ }
+ content = StringUtil.expandUsingJson(content, json, "%");
+ if (content.contains("%{")) {
+ System.err.print("CONTENT 2" + content);
+ }
+ content = decryptString(content);
+ buf.append(content).append("\n");
+ buf.append("EOF_CONFIG").append("\n");
+ if (m2.containsKey("owner")) {
+ buf.append("chown ").append(m2.get("owner")).append(" ").append(m2.get("destination")).append("\n");
+ }
+ }
+ return buf.toString();
+ }
+
+ private String decryptString(String content) {
+ Pattern p = Pattern.compile("(rsa:[A-Za-z0-9+/]+ *[A-Za-z0-9+/]+ *[A-Za-z0-9+/]+=*)");
+ Matcher m = p.matcher(content);
+ StringBuffer s = new StringBuffer();
+ while (m.find()) {
+ String k = m.group(1);
+ m.appendReplacement(s, JavaHttpClient.decryptPassword(k));
+ }
+ m.appendTail(s);
+ return s.toString();
+ }
+
+ protected String userdataSshSetup(String id) {
+ StringBuffer buf = new StringBuffer();
+ if (id == null) {
+ buf.append("### userdataSshSetup null ID: ").append("\n");
+ return buf.toString();
+ }
+ buf.append("mkdir /home/ID/.ssh\n".replace("ID", id));
+ buf.append("chmod og-rwx /home/ID/.ssh\n".replace("ID", id));
+ buf.append("chown -R ID:ID /home/ID/.ssh\n".replace("ID", id));
+ buf.append("touch /home/ID/.ssh/authorized_keys\n".replace("ID", id));
+ buf.append("chmod og-rwx /home/ID/.ssh/authorized_keys\n".replace("ID", id));
+ buf.append("chown -R ID:ID /home/ID/.ssh/authorized_keys\n".replace("ID", id));
+ return buf.toString();
+ }
+
+ protected String userdataSshKey(String id, String publicKey) {
+ StringBuffer buf = new StringBuffer();
+ if (id == null) {
+ return "";
+ }
+ if (publicKey == null) {
+ buf.append("### null key: ").append(id).append("\n");
+ return buf.toString();
+ }
+ buf.append("echo ").append(publicKey.trim()).append(" >> /home/").append(id).append("/.ssh/authorized_keys\n");
+ return buf.toString();
+ }
+
+ protected Object userdataCertificate(DcaeBasicServer s) {
+ StringBuffer buf = new StringBuffer();
+ byte[] cert;
+ try {
+ cert = getTemplateBinary(s.getName() + ".pkcs12");
+ // buf.append("### check sum: " +
+ // MD5Checksum.createChecksum(cert)).append("\n");
+ buf.append("cat > /tmp/certificate.pkcs12.b64code << EOF_CERT").append("\n");
+ buf.append(B64Code.encode(cert)).append("\n");
+ buf.append("EOF_CERT").append("\n");
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ buf.append("## UNABLE TO FIND CERTIFICATE FOR: " + s.getName()).append("\n");
+ }
+ return buf.toString();
+ }
+
+ protected Object userdataCertificatePassword(DcaeBasicServer s) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("echo ").append(JavaHttpClient.decryptPassword(s.getCertificatePassword()))
+ .append(" > /tmp/.password\n");
+ return buf.toString();
+ }
+
+ protected String userdataHosts(DcaeBasicServer s, HashMap<DcaeBasicServer, Port> portMap) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("cat >> /etc/hosts << HOSTS_EOF").append("\n");
+ for (DcaeBasicServer s1 : portMap.keySet()) {
+ for (FixedIp x : portMap.get(s1).getFixed_ips()) {
+ buf.append(x.getIp_address() + " " + dnsName(s1) + " " + s1.getName()).append("\n");
+ }
+ }
+ buf.append("HOSTS_EOF").append("\n");
+ buf.append("echo ").append(s.getName()).append(" > /etc/hostname\n");
+ int index = 0;
+ for (DcaeBasicServer s1 : portMap.keySet()) {
+ for (FixedIp x : portMap.get(s1).getFixed_ips()) {
+ buf.append("IP" + index + "=").append(x.getIp_address()).append("\n");
+ }
+ index++;
+ }
+ return buf.toString();
+ }
+
+ protected static String getTemplate(String resource) throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ byte[] data = new byte[65536];
+ InputStream is = DcaeVirtualMachineServiceProvider.class.getClassLoader().getResourceAsStream(resource);
+ if (is == null) {
+ throw new RuntimeException("Unable to find resource: " + resource);
+ }
+ int i;
+ try {
+ while ((i = is.read(data)) > 0) {
+ baos.write(data, 0, i);
+ }
+ } catch (Exception e) {
+ ManagementServerUtils.printStackTrace(e);
+ } finally {
+ if (is != null) {
+ is.close();
+ }
+ }
+ return (new String(baos.toByteArray()));
+ }
+
+ static byte[] getTemplateBinary(String rnm) throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ byte[] data = new byte[65536];
+ InputStream is = DcaeVirtualMachineServiceProvider.class.getClassLoader().getResourceAsStream(rnm);
+ int i;
+ try {
+ while ((i = is.read(data)) > 0) {
+ baos.write(data, 0, i);
+ }
+ } catch (Exception e) {
+ ManagementServerUtils.printStackTrace(e);
+ } finally {
+ if (is != null) {
+ is.close();
+ }
+ }
+ return baos.toByteArray();
+ }
+
+ protected Object userdataFromFile(String name, VirtualMachineServiceInstance i, DcaeBasicServer s2) {
+ try {
+ String s = getTemplate(name + ".userdata");
+ JSONObject json = new JSONObject();
+ DcaeBasicServerNetwork n = s2.getNetworks().get(0);
+ String dns = n.getDnsName();
+ json.put("dnsDomain", dns.substring(dns.indexOf(".") + 1));
+ json.put("admin", i.getIedsAdmin());
+ return StringUtil.expandUsingJson(s, json, "%");
+ } catch (Exception e) {
+ return "#error " + name + ".userdata: " + e;
+ }
+ }
+
+
+ protected String userdataInitial() {
+ StringBuffer buf = new StringBuffer();
+ buf.append("#!/bin/bash").append("\n");
+ buf.append("cat > /tmp/dcae_install.sh << EOF_DCAE_INSTALL").append("\n");
+ buf.append("#!/bin/bash").append("\n");
+ buf.append("set -x").append("\n");
+ buf.append("cd /tmp").append("\n");
+ return buf.toString();
+ }
+
+ protected String userdataFinal(VirtualMachineServiceInstance i, DcaeBasicServer s) {
+ StringBuffer buf = new StringBuffer();
+ buf.append("EOF_DCAE_INSTALL").append("\n");
+ buf.append(userdataCertificatePassword(s));
+ buf.append("bash /tmp/dcae_install.sh 2>&1 | tee /tmp/dcae_install.log").append("\n");
+ return buf.toString();
+ }
+
+ public void undeploy(java.lang.String instanceName) {
+ if (o.getName().equals("vm-controller")) {
+ throw new RuntimeException("Cannot undeploy vm-controller, please use Horizon");
+ }
+ VirtualMachineServiceInstance i = findInstance(instanceName);
+ for (int j = 0; j < i.getNumberOfServers(); j++) {
+ // System.out.println("HHHH: " + i.getServers().get(j).getName());
+ if (i.getLocation() == null) {
+ continue;
+ }
+ OpenStackLocation loc = (OpenStackLocation) i.getLocation().getOpenstackProject().eContainer();
+ String tname = i.getLocation().getOpenstackProject().getName();
+ loc.deleteServer(tname, vmName(i, j));
+ // System.out.println("HHHH deleted: " + vmName(i, j));
+ }
+ }
+
+ protected static String dnsName(DcaeBasicServer s) {
+ return s.getNetworks().get(0).getDnsName();
+ }
+
+ public void updateDeploymentStatus() {
// System.out.println("XXXX updateDeploymentStatus: " + o.getName());
- for (VirtualMachineServiceInstance instance : o.getInstances()) {
+ for (VirtualMachineServiceInstance instance : o.getInstances()) {
// System.out.println("XXXX updateDeploymentStatus: " + o.getName() + " " + instance.getName() + " "
// + instance.getServers().size());
- if (instance.getServers().size() == 0) {
- setStatus(instance,DeploymentStatus.UNDEPLOYED,"no servers");
- continue;
- }
- if (instance.getServers().size() != instance.getNumberOfServers()) {
- setStatus(instance,DeploymentStatus.DEPLOYED_ERRORS,"not the right number of servers");
- continue;
- }
- if (instance.getVmType() == null) {
- logger.warn("virtual machine instance without vmType: " + ManagementServer.object2ref(instance));
- setStatus(instance,DeploymentStatus.DEPLOYED_ERRORS,"vm type is null");
- continue;
- }
- boolean allPhysical = true;
- for (int j = 0; j < instance.getNumberOfServers(); j++) {
- DcaeBasicServer s1 = instance.getServers().get(j);
- // check if server is non Openstack managed VM.
- if (s1 instanceof PhysicalMachine) {
- continue;
- }
- allPhysical = false;
- }
- if (allPhysical) {
- setStatus(instance,DeploymentStatus.DEPLOYED,"all physical");
- continue;
- }
- if (instance.getLocation() == null) {
- setStatus(instance,DeploymentStatus.UNDEPLOYED,"no location");
- continue;
- }
- boolean needPubIp = instance.getVmType().isNeedPublicIp();
- boolean errors = false;
- String incomplete = null;
- int numDeployed = 0;
- for (int j = 0; j < instance.getNumberOfServers(); j++) {
- DcaeBasicServer s1 = instance.getServers().get(j);
- // check if server is non Openstack managed VM.
- if (s1 instanceof PhysicalMachine) {
- numDeployed++;
- continue;
- }
- // VirtualMachine vm = (VirtualMachine) s1;
- String n = vmName(instance, j);
- if (!s1.getName().equals(n)) {
- errors = true;
- }
- Server svr = null;
- String privateip = null;
- String publicip = null;
- s1.setServer(null);
- s1.setPrivateIp(null);
- s1.setPublicIp(null);
- OpenStackProject project = instance.getLocation().getOpenstackProject();
- for (Server s : project.getServers()) {
- if (n.equals(s.getName())) {
- svr = s;
- for (Addresses a : s.getAddresses()) {
+ if (instance.getServers().size() == 0) {
+ setStatus(instance, DeploymentStatus.UNDEPLOYED, "no servers");
+ continue;
+ }
+ if (instance.getServers().size() != instance.getNumberOfServers()) {
+ setStatus(instance, DeploymentStatus.DEPLOYED_ERRORS, "not the right number of servers");
+ continue;
+ }
+ if (instance.getVmType() == null) {
+ logger.warn("virtual machine instance without vmType: " + ManagementServer.object2ref(instance));
+ setStatus(instance, DeploymentStatus.DEPLOYED_ERRORS, "vm type is null");
+ continue;
+ }
+ boolean allPhysical = true;
+ for (int j = 0; j < instance.getNumberOfServers(); j++) {
+ DcaeBasicServer s1 = instance.getServers().get(j);
+ // check if server is non Openstack managed VM.
+ if (s1 instanceof PhysicalMachine) {
+ continue;
+ }
+ allPhysical = false;
+ }
+ if (allPhysical) {
+ setStatus(instance, DeploymentStatus.DEPLOYED, "all physical");
+ continue;
+ }
+ if (instance.getLocation() == null) {
+ setStatus(instance, DeploymentStatus.UNDEPLOYED, "no location");
+ continue;
+ }
+ boolean needPubIp = instance.getVmType().isNeedPublicIp();
+ boolean errors = false;
+ String incomplete = null;
+ int numDeployed = 0;
+ for (int j = 0; j < instance.getNumberOfServers(); j++) {
+ DcaeBasicServer s1 = instance.getServers().get(j);
+ // check if server is non Openstack managed VM.
+ if (s1 instanceof PhysicalMachine) {
+ numDeployed++;
+ continue;
+ }
+ // VirtualMachine vm = (VirtualMachine) s1;
+ String n = vmName(instance, j);
+ if (!s1.getName().equals(n)) {
+ errors = true;
+ }
+ Server svr = null;
+ String privateip = null;
+ String publicip = null;
+ s1.setServer(null);
+ s1.setPrivateIp(null);
+ s1.setPublicIp(null);
+ OpenStackProject project = instance.getLocation().getOpenstackProject();
+ for (Server s : project.getServers()) {
+ if (n.equals(s.getName())) {
+ svr = s;
+ for (Addresses a : s.getAddresses()) {
// System.out.println("RRRR: " + o.getName() + " " + instance.getName() + " " + s.getName()
// + " " + a.getName());
- for (Address ip : a.getIps()) {
- if (ip.getOS_EXT_IPS_type() == null || ip.getOS_EXT_IPS_type().equals("fixed")) {
- if (a.getName().equals(project.getPrivateNetwork()))
- privateip = ip.getAddr();
- if (a.getName().equals("public") && ip.getVersion() == 4)
- publicip = ip.getAddr();
- }
- if (ip.getOS_EXT_IPS_type() != null && ip.getOS_EXT_IPS_type().equals("floating")) {
- publicip = ip.getAddr();
- }
- }
- }
- }
- }
- s1.setPrivateIp(privateip);
- s1.setPublicIp(publicip);
- s1.setServer(svr);
- if (svr != null && svr.getOS_EXT_STS_vm_state().equals("active"))
- numDeployed++;
- if (publicip == null && needPubIp && project.getPublicNetwork() != null) {
- incomplete = s1.getName() + " has not public IP";
- }
- if (privateip == null) {
- incomplete = s1.getName() + " has not private IP";
- }
- if (svr == null) {
- incomplete = s1.getName() + " has null openstack server";
- }
- }
+ for (Address ip : a.getIps()) {
+ if (ip.getOS_EXT_IPS_type() == null || ip.getOS_EXT_IPS_type().equals("fixed")) {
+ if (a.getName().equals(project.getPrivateNetwork())) {
+ privateip = ip.getAddr();
+ }
+ if (a.getName().equals("public") && ip.getVersion() == 4) {
+ publicip = ip.getAddr();
+ }
+ }
+ if (ip.getOS_EXT_IPS_type() != null && ip.getOS_EXT_IPS_type().equals("floating")) {
+ publicip = ip.getAddr();
+ }
+ }
+ }
+ }
+ }
+ s1.setPrivateIp(privateip);
+ s1.setPublicIp(publicip);
+ s1.setServer(svr);
+ if (svr != null && svr.getOS_EXT_STS_vm_state().equals("active")) {
+ numDeployed++;
+ }
+ if (publicip == null && needPubIp && project.getPublicNetwork() != null) {
+ incomplete = s1.getName() + " has not public IP";
+ }
+ if (privateip == null) {
+ incomplete = s1.getName() + " has not private IP";
+ }
+ if (svr == null) {
+ incomplete = s1.getName() + " has null openstack server";
+ }
+ }
// System.out.println("XXXX updateDeploymentStatus: " + o.getName() + " " + instance.getName() + " " + errors
// + " " + numDeployed + " " + incomplete);
- if (errors) {
- setStatus(instance,DeploymentStatus.DEPLOYED_ERRORS,"errors");
- } else if (numDeployed == 0) {
- setStatus(instance,DeploymentStatus.UNDEPLOYED,"numDeployed == 0");
- } else if (incomplete != null) {
- setStatus(instance,DeploymentStatus.DEPLOYED_PARTIALLY,incomplete);
- } else {
- setStatus(instance,DeploymentStatus.DEPLOYED,"all okay");
- }
- }
-
- };
-
- protected void setStatus(VirtualMachineServiceInstance instance, DeploymentStatus newStatus,String reason) {
- if (instance.getStatus() != newStatus) {
- String msg = "deployment status changed: " + ManagementServer.object2ref(instance) +
- " " + instance.getStatus() + " -> " + newStatus + " " + reason;
- System.err.println("VMDEPLOYMENTSTATUS: " + new Date() + " " + msg);
- logger.info(msg);
- }
- instance.setStatus(newStatus);
- }
-
- public HealthTestResponse test(String instance) {
- VirtualMachineServiceInstance i = findInstance(instance);
- HealthTestResponse res = ServiceFactory.eINSTANCE.createHealthTestResponse();
- res.setStatus(HealthTestStatus.GREEN);
- for (DcaeBasicServer s : i.getServers()) {
- try {
- AbstractClient c = getClient(i,s);
- DcaeVirtualMachineManagerConsole console = new DcaeVirtualMachineManagerConsole(c);
- HealthTestResponse h = console.test();
- s.setHealthTestStatus(h.getStatus());
- s.setHealthTestMessageCode(h.getMessageCode());
- updateHealthResponse(res,h);
- } catch (Exception e) {
- res.setStatus(HealthTestStatus.RED);
- res.setMessageCode("Health check failed to server: " + s.getName() + " " + e);
- }
- }
- return res;
- }
-
- protected void updateHealthResponse(HealthTestResponse h, HealthTestResponse h1) {
- if (h.getStatus() == HealthTestStatus.RED) return;
- if (h.getStatus() == HealthTestStatus.YELLOW && h1.getStatus() != HealthTestStatus.RED) return;
- if (h.getStatus() == HealthTestStatus.GREEN && h1.getStatus() == HealthTestStatus.GREEN) return;
- // h1 should be used
- h.setStatus(h1.getStatus());
- h.setMessageCode(h1.getMessageCode());
- }
-
- public void suspend(String instance) {
- VirtualMachineServiceInstance i = findInstance(instance);
- for (DcaeBasicServer s : getServers(i)) {
- AbstractClient c = getClient(i, s);
- DcaeVirtualMachineManagerConsole console = new DcaeVirtualMachineManagerConsole(c);
- console.suspend();
- }
- }
-
- public void resume(String instance) {
- VirtualMachineServiceInstance i = findInstance(instance);
- for (DcaeBasicServer s : getServers(i)) {
- AbstractClient c = getClient(i,s);
- DcaeVirtualMachineManagerConsole console = new DcaeVirtualMachineManagerConsole(c);
- console.resume();
- }
- }
-
- public void pushManagerConfiguration(String instance) {
- VirtualMachineServiceInstance i = findInstance(instance);
- for (DcaeBasicServer s : getServers(i)) {
- AbstractClient c = getClient(i, s);
- DcaeVirtualMachineManagerConsole console = new DcaeVirtualMachineManagerConsole(c);
- EObject config = o.managerConfiguration(instance);
- console.update("/", ManagementServer.ensureHardUpdate(config, 1));
- EList<DcaeStream> l1 = new BasicEList<DcaeStream>();
- l1.addAll(EcoreUtil.copyAll(i.getInputStreams()));
- EList<DcaeStream> l2 = new BasicEList<DcaeStream>();
- l2.addAll(EcoreUtil.copyAll(i.getOutputStreams()));
- console.updateStreams(decrypt(l1), decrypt(l2));
- console.configurationChanged();
- }
- }
-
- protected EList<DcaeStream> decrypt(EList<DcaeStream> l) {
- for (DcaeStream s : l) {
- if (s instanceof DmaapStream) {
- DmaapStream s1 = (DmaapStream) s;
- s1.setDmaapPassword(JavaHttpClient.decryptPassword(s1.getDmaapPassword()));
- }
- }
- return l;
- }
-
- protected EList<DcaeBasicServer> getServers(VirtualMachineServiceInstance i) {
- return i.getServers();
- }
-
- protected EObject convertToManagerConfiguration(VirtualMachineServiceInstance i) {
- VirtualMachineServiceConfiguration c = VmFactory.eINSTANCE.createVirtualMachineServiceConfiguration();
- c.setConfiguration(i.getConfiguration());
- return c;
- }
-
- public void pollManagerConfiguration(String instance) {
- // TODO Auto-generated method stub
-
- }
-
- public void start() {
- Thread t = new Thread("vm service: " + o.getName()) {
- @Override
- public void run() {
- while (true) {
- try {
- if (!controller.getServer().isSlave)
- updateDeploymentStatus();
- Thread.sleep(10000); // sleep 10 seconds
- } catch (Exception e) {
- ManagementServerUtils.printStackTrace(e);
- logger.fatal("vm service: " + o.getName() + " : " + e);
- try {
- Thread.sleep(30000);
- } catch (InterruptedException e1) {
- }
- }
- }
- }
-
- };
- t.start();
- }
-
- public AbstractClient getClient(VirtualMachineServiceInstance i, DcaeBasicServer s) {
- JavaHttpClient c = new JavaHttpClient("managers.properties", i.eClass().getInstanceClassName());
- if (c.getBaseAddress() == null) {
- throw new RuntimeException("unable to determine baseaddress in managers.properties for: "
- + i.eClass().getInstanceClassName());
- }
- if (i.getServers().size() == 0) {
- throw new RuntimeException("service instances is not deployed (has no servers): "
- + ManagementServer.object2ref(i));
- }
- int port = i.getService().getManagerPortNumber();
- if (i.getManagerPortNumber() != null)
- port = i.getManagerPortNumber();
- if (s instanceof PhysicalMachine) {
- PhysicalMachine p = (PhysicalMachine) s;
- if (p.getManagerPortNumber() != null)
- port = p.getManagerPortNumber();
- }
- String b = c.getBaseAddress();
- b = b.replaceFirst("PORT", Integer.toString(port));
- b = b.replaceFirst("IP", dnsName(s));
- if (s.getCertificatePassword() != null)
- b = b.replaceFirst("http", "https");
- c.setBaseAddress(b);
- logger.info("using baseAdress: " + c.getBaseAddress() + " for " + ManagementServer.object2ref(i));
- return c;
- }
-
- public AbstractClient getClient(VirtualMachineServiceInstance i) {
- if (i.getLeaderServer() == null) {
- EList<DcaeBasicServer> l = getServers(i);
- if (l.size() == 0) {
- throw new RuntimeException("No servers for vm instance: " + ManagementServer.object2ref(i));
- }
- i.setLeaderServer(l.get(0));
- }
- return getClient(i, i.getLeaderServer());
- }
-
- protected String vmName(VirtualMachineServiceInstance i, int index) {
- return i.getServers().get(index).getName();
- // return "dcae:" + o.getName() + ":" + i.getName() + ":" + index;
- }
-
- protected VirtualMachineServiceInstance findInstance(String instanceName) {
- for (VirtualMachineServiceInstance ii : o.getInstances()) {
- if (ii.getName().equals(instanceName)) {
- return ii;
- }
- }
- throw new RuntimeException("Unable to find instance: " + instanceName);
- }
-
- public static void ecoreSetup() {
- // TODO Auto-generated method stub
-
- }
-
- public EObject managerConfiguration(String instanceName) {
- VirtualMachineServiceInstance i = findInstance(instanceName);
- AbstractClient c = getClient(i);
- DcaeVirtualMachineManagerConsole console = new DcaeVirtualMachineManagerConsole(c);
- Object oo = console.list("/", 100);
- JSONObject json = (JSONObject) Utils.object2json(oo);
- // System.err.println("XXXXX" + json.toString(2));
- return controller.getServer().json2ecore(EcorePackage.eINSTANCE.getEObject(), json);
- }
-
- public JSONObject managerOperation(String instanceName, String operation, JSONObject parameters) {
- VirtualMachineServiceInstance i = findInstance(instanceName);
- AbstractClient c = getClient(i);
- DcaeVirtualMachineManagerConsole console = new DcaeVirtualMachineManagerConsole(c);
- if (operation == null)
- throw new RuntimeException("no operation: " + instanceName);
- if (parameters == null)
- throw new RuntimeException("no parameters: " + instanceName + "@" + operation);
- Object oo = console.operation("/", operation, parameters);
- if (oo == null)
- return null;
- JSONObject json = (JSONObject) Utils.object2json(oo);
- // System.err.println("XXXXX" + json.toString(2));
- return json;
- }
-
- public void runHealthTests() {
- // TODO is this every called??
- System.err.println("TTTTTTTTT vm runHealthTests");
- for (VirtualMachineServiceInstance i : o.getInstances()) {
- HealthTestResponse s = null;
- try {
- if (i.getStatus() == DeploymentStatus.DEPLOYED) {
- if (i.getManagerPortNumber() < 0) {
- s = ServiceFactory.eINSTANCE.createHealthTestResponse();
- s.setMessageCode("Health Check undefined");
- s.setStatus(HealthTestStatus.YELLOW);
- } else {
- AbstractClient c = getClient(i);
- DcaeVirtualMachineManagerConsole console = new DcaeVirtualMachineManagerConsole(c);
- s = console.test();
- }
- } else {
- s = ServiceFactory.eINSTANCE.createHealthTestResponse();
- s.setMessageCode("Not deployed");
- s.setStatus(HealthTestStatus.YELLOW);
- }
- } catch (Exception e) {
- s = ServiceFactory.eINSTANCE.createHealthTestResponse();
- s.setMessageCode(e.toString());
- s.setStatus(HealthTestStatus.RED);
- }
- i.setHealthTestStatus(s.getStatus());
- i.setHealthTestMessageCode(s.getMessageCode());
- MetricStore store = controller.getServer().metrics.getStore(i);
- Date now = new Date();
- String path = "/lastHealthTest";
- store.addLongValue(path, now, now.getTime(), "DateMetricAttribute", false);
- }
- }
-
- public void updateConfigurationFromPolicy(String instanceName) {
- throw new UnsupportedOperationException("should not get called");
- }
+ if (errors) {
+ setStatus(instance, DeploymentStatus.DEPLOYED_ERRORS, "errors");
+ } else if (numDeployed == 0) {
+ setStatus(instance, DeploymentStatus.UNDEPLOYED, "numDeployed == 0");
+ } else if (incomplete != null) {
+ setStatus(instance, DeploymentStatus.DEPLOYED_PARTIALLY, incomplete);
+ } else {
+ setStatus(instance, DeploymentStatus.DEPLOYED, "all okay");
+ }
+ }
+
+ }
+
+ ;
+
+ protected void setStatus(VirtualMachineServiceInstance instance, DeploymentStatus newStatus, String reason) {
+ if (instance.getStatus() != newStatus) {
+ String msg = "deployment status changed: " + ManagementServer.object2ref(instance) +
+ " " + instance.getStatus() + " -> " + newStatus + " " + reason;
+ System.err.println("VMDEPLOYMENTSTATUS: " + new Date() + " " + msg);
+ logger.info(msg);
+ }
+ instance.setStatus(newStatus);
+ }
+
+ public HealthTestResponse test(String instance) {
+ VirtualMachineServiceInstance i = findInstance(instance);
+ HealthTestResponse res = ServiceFactory.eINSTANCE.createHealthTestResponse();
+ res.setStatus(HealthTestStatus.GREEN);
+ for (DcaeBasicServer s : i.getServers()) {
+ try {
+ AbstractClient c = getClient(i, s);
+ DcaeVirtualMachineManagerConsole console = new DcaeVirtualMachineManagerConsole(c);
+ HealthTestResponse h = console.test();
+ s.setHealthTestStatus(h.getStatus());
+ s.setHealthTestMessageCode(h.getMessageCode());
+ updateHealthResponse(res, h);
+ } catch (Exception e) {
+ res.setStatus(HealthTestStatus.RED);
+ res.setMessageCode("Health check failed to server: " + s.getName() + " " + e);
+ }
+ }
+ return res;
+ }
+
+ protected void updateHealthResponse(HealthTestResponse h, HealthTestResponse h1) {
+ if (h.getStatus() == HealthTestStatus.RED) {
+ return;
+ }
+ if (h.getStatus() == HealthTestStatus.YELLOW && h1.getStatus() != HealthTestStatus.RED) {
+ return;
+ }
+ if (h.getStatus() == HealthTestStatus.GREEN && h1.getStatus() == HealthTestStatus.GREEN) {
+ return;
+ }
+ // h1 should be used
+ h.setStatus(h1.getStatus());
+ h.setMessageCode(h1.getMessageCode());
+ }
+
+ public void suspend(String instance) {
+ VirtualMachineServiceInstance i = findInstance(instance);
+ for (DcaeBasicServer s : getServers(i)) {
+ AbstractClient c = getClient(i, s);
+ DcaeVirtualMachineManagerConsole console = new DcaeVirtualMachineManagerConsole(c);
+ console.suspend();
+ }
+ }
+
+ public void resume(String instance) {
+ VirtualMachineServiceInstance i = findInstance(instance);
+ for (DcaeBasicServer s : getServers(i)) {
+ AbstractClient c = getClient(i, s);
+ DcaeVirtualMachineManagerConsole console = new DcaeVirtualMachineManagerConsole(c);
+ console.resume();
+ }
+ }
+
+ public void pushManagerConfiguration(String instance) {
+ VirtualMachineServiceInstance i = findInstance(instance);
+ for (DcaeBasicServer s : getServers(i)) {
+ AbstractClient c = getClient(i, s);
+ DcaeVirtualMachineManagerConsole console = new DcaeVirtualMachineManagerConsole(c);
+ EObject config = o.managerConfiguration(instance);
+ console.update("/", ManagementServer.ensureHardUpdate(config, 1));
+ EList<DcaeStream> l1 = new BasicEList<DcaeStream>();
+ l1.addAll(EcoreUtil.copyAll(i.getInputStreams()));
+ EList<DcaeStream> l2 = new BasicEList<DcaeStream>();
+ l2.addAll(EcoreUtil.copyAll(i.getOutputStreams()));
+ console.updateStreams(decrypt(l1), decrypt(l2));
+ console.configurationChanged();
+ }
+ }
+
+ protected EList<DcaeStream> decrypt(EList<DcaeStream> l) {
+ for (DcaeStream s : l) {
+ if (s instanceof DmaapStream) {
+ DmaapStream s1 = (DmaapStream) s;
+ s1.setDmaapPassword(JavaHttpClient.decryptPassword(s1.getDmaapPassword()));
+ }
+ }
+ return l;
+ }
+
+ protected EList<DcaeBasicServer> getServers(VirtualMachineServiceInstance i) {
+ return i.getServers();
+ }
+
+ protected EObject convertToManagerConfiguration(VirtualMachineServiceInstance i) {
+ VirtualMachineServiceConfiguration c = VmFactory.eINSTANCE.createVirtualMachineServiceConfiguration();
+ c.setConfiguration(i.getConfiguration());
+ return c;
+ }
+
+ public void pollManagerConfiguration(String instance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void start() {
+ Thread t = new Thread("vm service: " + o.getName()) {
+ @Override
+ public void run() {
+ while (true) {
+ try {
+ if (!controller.getServer().isSlave) {
+ updateDeploymentStatus();
+ }
+ Thread.sleep(10000); // sleep 10 seconds
+ } catch (Exception e) {
+ ManagementServerUtils.printStackTrace(e);
+ logger.fatal("vm service: " + o.getName() + " : " + e);
+ try {
+ Thread.sleep(30000);
+ } catch (InterruptedException e1) {
+ }
+ }
+ }
+ }
+
+ };
+ t.start();
+ }
+
+ public AbstractClient getClient(VirtualMachineServiceInstance i, DcaeBasicServer s) {
+ JavaHttpClient c = new JavaHttpClient("managers.properties", i.eClass().getInstanceClassName());
+ if (c.getBaseAddress() == null) {
+ throw new RuntimeException("unable to determine baseaddress in managers.properties for: "
+ + i.eClass().getInstanceClassName());
+ }
+ if (i.getServers().size() == 0) {
+ throw new RuntimeException("service instances is not deployed (has no servers): "
+ + ManagementServer.object2ref(i));
+ }
+ int port = i.getService().getManagerPortNumber();
+ if (i.getManagerPortNumber() != null) {
+ port = i.getManagerPortNumber();
+ }
+ if (s instanceof PhysicalMachine) {
+ PhysicalMachine p = (PhysicalMachine) s;
+ if (p.getManagerPortNumber() != null) {
+ port = p.getManagerPortNumber();
+ }
+ }
+ String b = c.getBaseAddress();
+ b = b.replaceFirst("PORT", Integer.toString(port));
+ b = b.replaceFirst("IP", dnsName(s));
+ if (s.getCertificatePassword() != null) {
+ b = b.replaceFirst("http", "https");
+ }
+ c.setBaseAddress(b);
+ logger.info("using baseAdress: " + c.getBaseAddress() + " for " + ManagementServer.object2ref(i));
+ return c;
+ }
+
+ public AbstractClient getClient(VirtualMachineServiceInstance i) {
+ if (i.getLeaderServer() == null) {
+ EList<DcaeBasicServer> l = getServers(i);
+ if (l.size() == 0) {
+ throw new RuntimeException("No servers for vm instance: " + ManagementServer.object2ref(i));
+ }
+ i.setLeaderServer(l.get(0));
+ }
+ return getClient(i, i.getLeaderServer());
+ }
+
+ protected String vmName(VirtualMachineServiceInstance i, int index) {
+ return i.getServers().get(index).getName();
+ // return "dcae:" + o.getName() + ":" + i.getName() + ":" + index;
+ }
+
+ protected VirtualMachineServiceInstance findInstance(String instanceName) {
+ for (VirtualMachineServiceInstance ii : o.getInstances()) {
+ if (ii.getName().equals(instanceName)) {
+ return ii;
+ }
+ }
+ throw new RuntimeException("Unable to find instance: " + instanceName);
+ }
+
+ public static void ecoreSetup() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public EObject managerConfiguration(String instanceName) {
+ VirtualMachineServiceInstance i = findInstance(instanceName);
+ AbstractClient c = getClient(i);
+ DcaeVirtualMachineManagerConsole console = new DcaeVirtualMachineManagerConsole(c);
+ Object oo = console.list("/", 100);
+ JSONObject json = (JSONObject) Utils.object2json(oo);
+ // System.err.println("XXXXX" + json.toString(2));
+ return controller.getServer().json2ecore(EcorePackage.eINSTANCE.getEObject(), json);
+ }
+
+ public JSONObject managerOperation(String instanceName, String operation, JSONObject parameters) {
+ VirtualMachineServiceInstance i = findInstance(instanceName);
+ AbstractClient c = getClient(i);
+ DcaeVirtualMachineManagerConsole console = new DcaeVirtualMachineManagerConsole(c);
+ if (operation == null) {
+ throw new RuntimeException("no operation: " + instanceName);
+ }
+ if (parameters == null) {
+ throw new RuntimeException("no parameters: " + instanceName + "@" + operation);
+ }
+ Object oo = console.operation("/", operation, parameters);
+ if (oo == null) {
+ return null;
+ }
+ JSONObject json = (JSONObject) Utils.object2json(oo);
+ // System.err.println("XXXXX" + json.toString(2));
+ return json;
+ }
+
+ public void runHealthTests() {
+ // TODO is this every called??
+ System.err.println("TTTTTTTTT vm runHealthTests");
+ for (VirtualMachineServiceInstance i : o.getInstances()) {
+ HealthTestResponse s = null;
+ try {
+ if (i.getStatus() == DeploymentStatus.DEPLOYED) {
+ if (i.getManagerPortNumber() < 0) {
+ s = ServiceFactory.eINSTANCE.createHealthTestResponse();
+ s.setMessageCode("Health Check undefined");
+ s.setStatus(HealthTestStatus.YELLOW);
+ } else {
+ AbstractClient c = getClient(i);
+ DcaeVirtualMachineManagerConsole console = new DcaeVirtualMachineManagerConsole(c);
+ s = console.test();
+ }
+ } else {
+ s = ServiceFactory.eINSTANCE.createHealthTestResponse();
+ s.setMessageCode("Not deployed");
+ s.setStatus(HealthTestStatus.YELLOW);
+ }
+ } catch (Exception e) {
+ s = ServiceFactory.eINSTANCE.createHealthTestResponse();
+ s.setMessageCode(e.toString());
+ s.setStatus(HealthTestStatus.RED);
+ logger.error("exception occured ", e);
+ }
+ i.setHealthTestStatus(s.getStatus());
+ i.setHealthTestMessageCode(s.getMessageCode());
+ MetricStore store = controller.getServer().metrics.getStore(i);
+ Date now = new Date();
+ String path = "/lastHealthTest";
+ store.addLongValue(path, now, now.getTime(), "DateMetricAttribute", false);
+ }
+ }
+
+ public void updateConfigurationFromPolicy(String instanceName) {
+ throw new UnsupportedOperationException("should not get called");
+ }
}