diff options
Diffstat (limited to 'dcae-controller-core/dcae-controller-platform-server')
105 files changed, 9371 insertions, 0 deletions
diff --git a/dcae-controller-core/dcae-controller-platform-server/.classpath b/dcae-controller-core/dcae-controller-platform-server/.classpath new file mode 100644 index 0000000..5d4cb9c --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/.classpath @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="config"/> + <classpathentry kind="src" output="target/classes" path="src/main/java"> + <attributes> + <attribute name="optional" value="true"/> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="src" path="src/main/server"/> + <classpathentry kind="src" path="src/main/server-gen"/> + <classpathentry kind="src" path="src/main/sirius-gen"/> + <classpathentry kind="src" path="src/test/groovy"/> + <classpathentry kind="src" path="src/main/resources"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> + <attributes> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> + <attributes> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry exported="true" kind="con" path="GROOVY_SUPPORT"/> + <classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/> + <classpathentry kind="output" path="target/classes"/> +</classpath> diff --git a/dcae-controller-core/dcae-controller-platform-server/.gitignore b/dcae-controller-core/dcae-controller-platform-server/.gitignore new file mode 100644 index 0000000..eefdc10 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/.gitignore @@ -0,0 +1,3 @@ +/target/ +.*.sw? +/config/ diff --git a/dcae-controller-core/dcae-controller-platform-server/.project b/dcae-controller-core/dcae-controller-platform-server/.project new file mode 100644 index 0000000..68e4826 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/.project @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>dcae-controller-platform-server</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.m2e.core.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.groovy.core.groovyNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.eclipse.m2e.core.maven2Nature</nature> + <nature>org.eclipse.pde.PluginNature</nature> + </natures> +</projectDescription> diff --git a/dcae-controller-core/dcae-controller-platform-server/.settings/org.eclipse.core.resources.prefs b/dcae-controller-core/dcae-controller-platform-server/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 diff --git a/dcae-controller-core/dcae-controller-platform-server/.settings/org.eclipse.jdt.core.prefs b/dcae-controller-core/dcae-controller-platform-server/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..4ede96d --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning diff --git a/dcae-controller-core/dcae-controller-platform-server/.settings/org.eclipse.jdt.groovy.core.prefs b/dcae-controller-core/dcae-controller-platform-server/.settings/org.eclipse.jdt.groovy.core.prefs new file mode 100644 index 0000000..ae98fea --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/.settings/org.eclipse.jdt.groovy.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +groovy.compiler.level=24 diff --git a/dcae-controller-core/dcae-controller-platform-server/.settings/org.eclipse.m2e.core.prefs b/dcae-controller-core/dcae-controller-platform-server/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/dcae-controller-core/dcae-controller-platform-server/LICENSE.txt b/dcae-controller-core/dcae-controller-platform-server/LICENSE.txt new file mode 100644 index 0000000..30471b5 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/LICENSE.txt @@ -0,0 +1,22 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +ECOMP and OpenECOMP are trademarks and service marks of AT&T Intellectual Property. diff --git a/dcae-controller-core/dcae-controller-platform-server/META-INF/MANIFEST.MF b/dcae-controller-core/dcae-controller-platform-server/META-INF/MANIFEST.MF new file mode 100644 index 0000000..c8db2b0 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/META-INF/MANIFEST.MF @@ -0,0 +1,21 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: dcae-controller-platform-server +Bundle-SymbolicName: dcae-controller-platform-server +Bundle-Version: 0.1.0.qualifier +Export-Package: org.openecomp.dcae.controller.platform.server.tools, + org.openecomp.dcae.controller.platform.servers.controller +Require-Bundle: ncomp-core-types, + ncomp-sirius-manager-model, + ncomp-sirius-manager-server, + ncomp-sirius-manager-console, + ncomp-sirius-manager-generator, + dcae-controller-platform-model;bundle-version="0.1.0", + ncomp-utils-java;bundle-version="0.1.0", + ncomp-openstack-controller;bundle-version="0.1.0", + ncomp-openstack-model;bundle-version="0.1.0", + dcae-controller-core-model;bundle-version="0.1.0", + dcae-controller-service-vm-model, + operation-utils;bundle-version="0.1.0", + dcae-controller-service-cdap-model, + dcae-controller-service-docker-model diff --git a/dcae-controller-core/dcae-controller-platform-server/build.properties b/dcae-controller-core/dcae-controller-platform-server/build.properties new file mode 100644 index 0000000..e704e8b --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/build.properties @@ -0,0 +1,6 @@ +source.. = src/main/java/,\ + src/main/sirius-gen/ +bin.includes = META-INF/,\ + . +output.. = bin/,\ + target/classes/ diff --git a/dcae-controller-core/dcae-controller-platform-server/pom.xml b/dcae-controller-core/dcae-controller-platform-server/pom.xml new file mode 100644 index 0000000..4fa9c14 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/pom.xml @@ -0,0 +1,179 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.openecomp.dcae.controller</groupId> + <artifactId>dcae-controller-platform-server</artifactId> + <parent> + <groupId>org.openecomp.ncomp.sirius.manager</groupId> + <artifactId>ncomp-sirius-manager-base</artifactId> + <version>0.1.0-SNAPSHOT</version> + <relativePath>../../../dcae-org.openecomp.ncomp.sirius.manager/ncomp-sirius-manager-base</relativePath> + </parent> + + + + <pluginRepositories> + <!-- Black Duck plugin dependencies --> + <pluginRepository> + <id>JCenter</id> + <name>JCenter Repository</name> + <url>http://jcenter.bintray.com</url> + </pluginRepository> + + <pluginRepository> + <id>Restlet</id> + <name>Restlet Repository</name> + <url>http://maven.restlet.com</url> + </pluginRepository> + </pluginRepositories> +<build> + <plugins> + <!-- blackduck maven plugin --> + <plugin> + <groupId>com.blackducksoftware.integration</groupId> + <artifactId>hub-maven-plugin</artifactId> + <version>1.4.0</version> + <inherited>false</inherited> + <configuration> + <hubProjectName>${project.name}</hubProjectName> + <outputDirectory>${project.basedir}</outputDirectory> + </configuration> + <executions> + <execution> + <id>create-bdio-file</id> + <phase>package</phase> + <goals> + <goal>createHubOutput</goal> + </goals> + </execution> + </executions> + </plugin> + <!-- site maven plugin --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-site-plugin</artifactId> + <version>3.6</version> + <dependencies> + <dependency> + <groupId>org.apache.maven.wagon</groupId> + <artifactId>wagon-webdav-jackrabbit</artifactId> + <version>2.10</version> + </dependency> + </dependencies> + </plugin> + + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <version>2.6</version> + <executions> + <execution> + <id>zipfile</id> + <goals> + <goal>single</goal> + </goals> + <phase>package</phase> + <configuration> + <attach>false</attach> + <finalName>${project.artifactId}-${project.version}</finalName> + <descriptors> + <descriptor>src/assembly/assemble_zip.xml</descriptor> + </descriptors> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <version>2.8</version> + <executions> + <execution> + <id>copy-dependencies</id> + <goals> + <goal>copy-dependencies</goal> + </goals> + <phase>prepare-package</phase> + <configuration> + <transitive>false</transitive> + <outputDirectory>${project.build.directory}/assembly/lib</outputDirectory> + <overWriteReleases>false</overWriteReleases> + <overWriteSnapshots>true</overWriteSnapshots> + <overWriteIfNewer>true</overWriteIfNewer> + <useRepositoryLayout>false</useRepositoryLayout> + <addParentPoms>false</addParentPoms> + <copyPom>false</copyPom> + <excludeGroupIds>org.opendaylight,com.brocade.odl,ch.qos.logback,org.bouncycastle</excludeGroupIds> + <includeScope>runtime</includeScope> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>1.10</version> + <executions> + <execution> + <id>attach-artifacts</id> + <phase>package</phase> + <goals> + <goal>attach-artifact</goal> + </goals> + <configuration> + <artifacts> + <artifact> + <file>target/${project.artifactId}-${project.version}-runtime.zip</file> + <type>zip</type> + <classifier>runtime</classifier> + </artifact> + </artifacts> + </configuration> + </execution> + </executions> + </plugin> + +</plugins> + </build> + <dependencies> + <dependency> + <groupId>org.openecomp.dcae.controller</groupId> + <artifactId>dcae-controller-platform-model</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.dcae.controller</groupId> + <artifactId>dcae-controller-service-vm-model</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.ncomp.openstack</groupId> + <artifactId>ncomp-openstack-controller</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.dcae.controller</groupId> + <artifactId>dcae-controller-service-vm-adaptor</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.dcae.operation</groupId> + <artifactId>operation-utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.dcae.controller</groupId> + <artifactId>dcae-controller-core-utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.dcae.controller</groupId> + <artifactId>dcae-controller-service-cdap-adaptor</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.dcae.controller</groupId> + <artifactId>dcae-controller-service-docker-adaptor</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> +</project> diff --git a/dcae-controller-core/dcae-controller-platform-server/src/assembly/assemble_zip.xml b/dcae-controller-core/dcae-controller-platform-server/src/assembly/assemble_zip.xml new file mode 100644 index 0000000..298661d --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/assembly/assemble_zip.xml @@ -0,0 +1,62 @@ +<!-- Defines how we build the .zip file which is our distribution. --> + +<assembly + xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> + <id>runtime</id> + <formats> + <format>zip</format> + </formats> + + <!-- we want "system" and related files right at the root level as this + file is suppose to be unzip on top of a karaf distro. --> + <includeBaseDirectory>false</includeBaseDirectory> + + <fileSets> + <fileSet> + <directory>target</directory> + <outputDirectory>lib</outputDirectory> + <includes> + <include>dcae-controller-platform-server-${project.version}.jar</include> + </includes> + </fileSet> + <fileSet> + <directory>target/assembly/</directory> + <outputDirectory>.</outputDirectory> + <excludes> + </excludes> + </fileSet> + <fileSet> + <directory>.</directory> + <outputDirectory>lib</outputDirectory> + <includes> + <include>*.jar</include> + </includes> + </fileSet> + <fileSet> + <directory>src/main/server-gen/bin</directory> + <outputDirectory>bin</outputDirectory> + <fileMode>0744</fileMode> + <excludes> + </excludes> + </fileSet> + <fileSet> + <directory>src/main/server/bin</directory> + <outputDirectory>bin</outputDirectory> + <fileMode>0744</fileMode> + <excludes> + </excludes> + </fileSet> + <fileSet> + <directory>src/main/server-gen/scripts</directory> + <outputDirectory>scripts</outputDirectory> + </fileSet> + <fileSet> + <directory>src/main/server/scripts</directory> + <outputDirectory>scripts</outputDirectory> + </fileSet> + + </fileSets> + +</assembly> diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/server/tools/Generator.java b/dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/server/tools/Generator.java new file mode 100644 index 0000000..d9bd272 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/server/tools/Generator.java @@ -0,0 +1,79 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +package org.openecomp.dcae.controller.platform.server.tools;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.openecomp.ncomp.sirius.manager.controllermodel.ControllerModel;
+import org.openecomp.ncomp.sirius.manager.controllermodel.ControllermodelFactory;
+import org.openecomp.ncomp.sirius.manager.generator.ControllerGenerator;
+import org.openecomp.ncomp.gwt.siriusportal.model.*;
+import org.openecomp.dcae.controller.platform.controller.ControllerFactory;
+import org.openecomp.dcae.controller.service.vm.VmFactory;
+import org.openecomp.utils.YamlToJava;
+
+
+public class Generator {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ EObject o = ControllerFactory.eINSTANCE.createDcaePlatformController();
+ EPackage p = o.eClass().getEPackage();
+ String dir = p.getNsURI().replaceAll(p.getNsPrefix()+'$',"") + "servers." + p.getNsPrefix();
+ dir= "src/main/sirius-gen/" + dir.replace('.', '/');
+ ControllerModel m = ControllermodelFactory.eINSTANCE.createControllerModel();
+ m.setTemplateDirectory("../../dcae-org.openecomp.ncomp.sirius.manager/ncomp-sirius-manager-generator/src/main/templates");
+ m.setPrefix("Dcae");
+ m.setPluginName(p.getNsURI());
+ m.setName("ControllerPlatformServer");
+ m.setTitle("ControllerPlatformServer");
+ ControllerGenerator g = new ControllerGenerator(o,m);
+ g.setEnableIRequestHandler(true);
+ g.setEnableISiriusPlugin(true);
+ g.setEnableISwaggerHandler(true);
+ EObject cluster = ControllerFactory.eINSTANCE.createControllerCluster();
+ g.addApi("cluster", cluster, m, false, true);
+ EObject cont = ControllerFactory.eINSTANCE.createControllerVirtualMachineService();
+ g.addApi("cont", cont, m, false, true);
+ EObject gui = ModelFactory.eINSTANCE.createGuiClientApi();
+ g.addObject("gui",gui,m);
+ g.addAlias("/test");
+ g.addAlias("/swagger");
+ g.addFactory("org.openecomp.ncomp.servers.openstack.OsOpenstackFactory");
+ g.addFactory("org.openecomp.ncomp.servers.openstack.loc.OsLocationFactory");
+ g.generate(dir);
+ g.generateScripts("src/main/server-gen/bin","controller-platform-server");
+ // create ECOMP Logging messages
+ String pName = p.getNsURI().replaceAll(p.getNsPrefix()+'$',"") + "servers." + p.getNsPrefix() +".logging";
+ YamlToJava.convert("src/main/resources/DcaeController.yaml", dir + "/logging", pName);
+ YamlToJava.convert("src/main/sirius-gen/DcaePlatformController.yaml", dir + "/logging", pName);
+ YamlToJava.convert("src/main/sirius-gen/ControllerCluster.yaml", dir + "/logging", pName);
+ YamlToJava.convert("src/main/sirius-gen/ControllerVirtualMachineService.yaml", dir + "/logging", pName);
+ String pName1 = p.getNsURI().replaceAll(p.getNsPrefix()+'$',"") + "servers." + p.getNsPrefix() +".gui.logging";
+ YamlToJava.convert("src/main/sirius-gen/GuiClientApi.yaml", dir + "/gui/logging", pName1);
+ }
+
+
+}
diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerClusterProvider.java b/dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerClusterProvider.java new file mode 100644 index 0000000..69644fd --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerClusterProvider.java @@ -0,0 +1,242 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +package org.openecomp.dcae.controller.platform.servers.controller; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.Date; + +import org.openecomp.ncomp.sirius.manager.GenericHttpClient; +import org.openecomp.ncomp.sirius.manager.ISiriusPlugin; +import org.openecomp.ncomp.sirius.manager.ISiriusServer; +import org.openecomp.ncomp.sirius.manager.Jetty8Client; +import org.openecomp.ncomp.sirius.manager.Jetty8ClientOld; +import org.openecomp.ncomp.sirius.manager.ManagementServer; +import org.openecomp.ncomp.sirius.manager.ManagementServerUtils; +import org.openecomp.ncomp.sirius.manager.Subject; + +import org.apache.log4j.Logger; +import org.json.JSONException; +import org.json.JSONObject; + +import org.openecomp.ncomp.sirius.manager.BasicAdaptorProvider; +import org.openecomp.ncomp.sirius.manager.metrics.MetricManager; +import org.openecomp.ncomp.webservice.utils.DateUtils; +import org.openecomp.dcae.controller.core.server.DcaeBasicServer; +import org.openecomp.dcae.controller.core.service.DcaeService; +import org.openecomp.dcae.controller.platform.controller.ControllerCluster; +import org.openecomp.dcae.controller.platform.controller.ControllerClusterServer; +import org.openecomp.dcae.controller.platform.controller.ControllerClusterServerData; +import org.openecomp.dcae.controller.platform.controller.DcaePlatformController; +import org.openecomp.dcae.controller.platform.controller.ServerRole; +import org.openecomp.dcae.controller.platform.servers.controller.logging.DcaeControllerMessageEnum; +import org.openecomp.dcae.controller.platform.servers.controller.logging.DcaeControllerOperationEnum; +import org.openecomp.dcae.controller.service.vm.PhysicalMachine; +import org.openecomp.dcae.controller.service.vm.VirtualMachineService; +import org.openecomp.dcae.controller.service.vm.VirtualMachineServiceInstance; +import org.openecomp.logger.EcompLogger; + +public class DcaeControllerClusterProvider extends BasicAdaptorProvider implements ISiriusPlugin { + private static final Logger logger = Logger.getLogger(DcaeControllerClusterProvider.class); + static final EcompLogger ecomplogger = EcompLogger.getEcompLogger(); + ControllerCluster o; + + public DcaeControllerClusterProvider(ISiriusServer controller, ControllerCluster o) { + super(controller, o); + this.o = o; + } + + public void pushData(String serverName, String dataName) { + ControllerClusterServer s = findServer(serverName); + ControllerClusterServerData d = findData(s, dataName); + DcaeControllerClusterConsole console = console(s); + Date now = new Date(); + MetricManager metrics = controller.getServer().metrics; + metrics.setDateMetric(d, "lastPush", new Date()); + metrics.addIncreasingULongMetric(d, "numberDataPushes", 1L, false); + try { + console.receiveData("/resources/cluster", o.getMyServerName(), dataName, now, getContent(dataName)); + } catch (Exception e) { + e.printStackTrace(); + metrics.addIncreasingULongMetric(d, "numberDataPushErrors", 1L, false); + } + } + + private ControllerClusterServer findServer(String serverName) { + for (ControllerClusterServer s : o.getServers()) { + if (s.getName().equals(serverName)) + return s; + } + throw new RuntimeException("Unknown server: " + serverName); + } + + private ControllerClusterServerData findData(ControllerClusterServer s, String name) { + for (ControllerClusterServerData d : s.getData()) { + if (d.getName().equals(name)) + return d; + } + throw new RuntimeException("Unknown date: " + name); + } + + private String getContent(String dataName) { + if (dataName.equals("state")) { + JSONObject json = ManagementServer.ecore2json(o.eContainer(), 10000, null, true); + if (json.has("cluster")) + json.remove("cluster"); + if (json.has("configuration")) + json.remove("configuration"); + if (json.has("component")) + json.remove("component"); + // json = new JSONObject(); + return json.toString(); + } + throw new RuntimeException("Unknown server: " + dataName); + } + + private DcaeControllerClusterConsole console(ControllerClusterServer s) { + DcaeControllerClusterClient c = new DcaeControllerClusterClient("console.properties", "localhost"); + GenericHttpClient client = (GenericHttpClient) c.client; + if (client.getBaseAddress() == null) { + throw new RuntimeException("unable to determine baseaddress in controller.properties for: cluster"); + } + String b = client.getBaseAddress(); + b = b.replaceFirst("localhost", s.getServer().getNetworks().get(0).getDnsName()); + client.setBaseAddress(b); + logger.info("using baseAdress: " + client.getBaseAddress()); + System.out.println("CLUSTER: " + client.getBaseAddress()); + return new DcaeControllerClusterConsole(client); + } + + public void receiveData(String serverName, String dataName, Date time, String content) { + if (o.getRole() != ServerRole.SLAVE) { + logger.info("Ignoring data replication since not slave"); + return; + } + ControllerClusterServer s = findServer(serverName); + ControllerClusterServerData d = findData(s, dataName); + MetricManager metrics = controller.getServer().metrics; + metrics.setDateMetric(d, "lastDataReceived", new Date()); + metrics.addIncreasingULongMetric(d, "numberDataReceived", 1L, false); + + try { + if (dataName.equals("state")) { + JSONObject json = new JSONObject(content); + json.put("$updateEnumWithDefault", 1); + json.put("$forcedUpdate", 1); + Subject s1 = new Subject(controller.getServer().getObject()); + controller.getServer().update("controller", s1, json, true); + } + } catch (Exception e) { + e.printStackTrace(); + metrics.addIncreasingULongMetric(d, "numberDataReceivedErrors", 1L, false); + } + } + + @Override + public void start() { + System.out.println("CLUSTER: start"); + try { + String hostname = InetAddress.getLocalHost().getHostName(); + if (hostname.indexOf(".") > 0) + hostname = hostname.substring(0, hostname.indexOf(".")); + o.setMyServerName(hostname); + Subject subject = controller.getServer().find("/services/vm-controller"); + VirtualMachineService service = (subject != null) ? (VirtualMachineService) subject.o : null; + if (service == null) { + logger.warn("No controller service"); + return; + } + for (ControllerClusterServer s : o.getServers()) { + for (VirtualMachineServiceInstance instance : service.getInstances()) { + for (DcaeBasicServer server : instance.getServers()) { + if (server.getName().equals(s.getName())) { + s.setServer(server); + } + } + } + } + } catch (UnknownHostException e) { + e.printStackTrace(); + } + System.out.println("CLUSTER: start"); + Thread t = new Thread("cluster replication") { + @Override + public void run() { + System.out.println("CLUSTER 2: run"); + ecomplogger.setOperation(DcaeControllerOperationEnum.CLUSTER_DATA_REPLICATION); + while (true) { + try { + System.out.println("CLUSTER 3: run"); + for (ControllerClusterServer s : o.getServers()) { + if (s.getName().equals(o.getMyServerName())) + o.setRole(s.getRole()); + } + controller.getServer().isSlave = o.getRole() == ServerRole.SLAVE; + if (o.getRole() == ServerRole.MASTER) { + System.out.println("CLUSTER 3: run"); + ecomplogger.newRequestId(); + ecomplogger.recordAuditEventStart(); + for (ControllerClusterServer s : o.getServers()) { + System.out.println("CLUSTER 4: run: " + s.getName() + " " + s.getRole()); + if (s.getRole() != ServerRole.SLAVE) + continue; + if (s.getName().equals(o.getMyServerName())) + continue; + System.out.println("CLUSTER 5: run"); + for (ControllerClusterServerData d : s.getData()) { + try { + System.out.println("CLUSTER 6: run: " + d.getName()); + Date last = d.getLastPush() == null ? null : d.getLastPush().last; + long i = DateUtils.stringToDuration(d.getPushInterval()); + System.out.println("CLUSTER 7: run"); + long now = new Date().getTime(); + if (last != null && last.getTime() + i > now) + continue; + System.out.println("CLUSTER 8: run"); + o.pushData(s.getName(), d.getName()); + System.out.println("CLUSTER 9: run"); + } catch (Exception e) { + ecomplogger.warn(DcaeControllerMessageEnum.CLUSTER_DATA_REPLICATION_FAILED, + s.getName()); + ManagementServerUtils.printStackTrace(e); + } + } + } + ecomplogger.recordAuditEventEnd(); + } + Thread.sleep(60000); // sleep 60 seconds + } catch (Exception e) { + ManagementServerUtils.printStackTrace(e); + logger.fatal("cluster replication: " + e); + try { + Thread.sleep(30000); + } catch (InterruptedException e1) { + } + } + } + } + + }; + t.start(); + } + +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerVirtualMachineServiceProvider.java b/dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerVirtualMachineServiceProvider.java new file mode 100644 index 0000000..4ab98ec --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerVirtualMachineServiceProvider.java @@ -0,0 +1,89 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +package org.openecomp.dcae.controller.platform.servers.controller; + +import org.openecomp.ncomp.sirius.manager.ISiriusServer; +import org.apache.log4j.Logger; +import org.openecomp.dcae.controller.core.service.HealthTestResponse; +import org.openecomp.dcae.controller.core.service.HealthTestStatus; +import org.openecomp.dcae.controller.core.service.ServiceFactory; +import org.openecomp.dcae.controller.core.stream.DatabusStream; +import org.openecomp.dcae.controller.core.stream.DatabusStreamFeed; +import org.openecomp.dcae.controller.core.stream.DatabusStreamTopic; +import org.openecomp.dcae.controller.core.stream.DatabusStreamTopicClient; +import org.openecomp.dcae.controller.platform.controller.ControllerVirtualMachineService; +import org.openecomp.dcae.controller.platform.controller.DcaePlatformController; +import org.openecomp.dcae.controller.service.servers.vm.DcaeVirtualMachineServiceProvider; + +public class DcaeControllerVirtualMachineServiceProvider extends DcaeVirtualMachineServiceProvider { + private static final Logger logger = Logger.getLogger(DcaeControllerVirtualMachineServiceProvider.class); + ControllerVirtualMachineService o; + + public DcaeControllerVirtualMachineServiceProvider(ISiriusServer controller, ControllerVirtualMachineService o) { + super(controller, o); + this.o = o; + } + + @Override + public HealthTestResponse test(String instance) { + DcaePlatformController c = (DcaePlatformController) o.eContainer(); + HealthTestResponse res = ServiceFactory.eINSTANCE.createHealthTestResponse(); + if (c.getDatabus() == null) { + res.setStatus(HealthTestStatus.RED); + res.setMessageCode("No Databus"); + return res; + } + if (c.getDatabus().getLocations().size() == 0) { + res.setStatus(HealthTestStatus.RED); + res.setMessageCode("No Databus Locations"); + return res; + } + for (DatabusStream s : c.getDatabus().getStreams()) { + if (s instanceof DatabusStreamFeed) { + DatabusStreamFeed f = (DatabusStreamFeed) s; + if (f.getFeedName() == null || f.getFeedName().startsWith("ERROR")) { + res.setStatus(HealthTestStatus.RED); + res.setMessageCode("Feed Error: " + f.getName()); + return res; + } + } + if (s instanceof DatabusStreamTopic) { + DatabusStreamTopic t = (DatabusStreamTopic) s; + if (t.getTopicName() == null || t.getTopicName().startsWith("ERROR")) { + res.setStatus(HealthTestStatus.RED); + res.setMessageCode("Topic Error: " + t.getName()); + return res; + } + for (DatabusStreamTopicClient client : t.getClients()) { + if (client.getTopicURL() == null) { + res.setStatus(HealthTestStatus.RED); + res.setMessageCode("Topic Error: null URL: " + t.getName() + "@" + client.getName()); + return res; + } + } + } + } + res.setStatus(HealthTestStatus.GREEN); + return res; + + } +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/servers/controller/DcaeDcaePlatformControllerProvider.java b/dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/servers/controller/DcaeDcaePlatformControllerProvider.java new file mode 100644 index 0000000..7574312 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/servers/controller/DcaeDcaePlatformControllerProvider.java @@ -0,0 +1,1158 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +package org.openecomp.dcae.controller.platform.servers.controller; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.math.BigInteger; +import java.security.SecureRandom; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; +import org.json.JSONArray; +import org.json.JSONObject; + +import org.openecomp.dcae.controller.core.server.DcaeBasicServer; +import org.openecomp.dcae.controller.core.service.DcaeLocation; +import org.openecomp.dcae.controller.core.service.DcaePolicyEntity; +import org.openecomp.dcae.controller.core.service.DcaeService; +import org.openecomp.dcae.controller.core.service.DcaeServiceInstance; +import org.openecomp.dcae.controller.core.stream.DatabusDataRouterNode; +import org.openecomp.dcae.controller.core.stream.DatabusEntity; +import org.openecomp.dcae.controller.core.stream.DatabusLocation; +import org.openecomp.dcae.controller.core.stream.DatabusMessageRouterCluster; +import org.openecomp.dcae.controller.core.stream.DatabusStream; +import org.openecomp.dcae.controller.core.stream.DatabusStreamFeed; +import org.openecomp.dcae.controller.core.stream.DatabusStreamFeedPublisher; +import org.openecomp.dcae.controller.core.stream.DatabusStreamFeedSubscriber; +import org.openecomp.dcae.controller.core.stream.DatabusStreamTopic; +import org.openecomp.dcae.controller.core.stream.DatabusStreamTopicAction; +import org.openecomp.dcae.controller.core.stream.DatabusStreamTopicClient; +import org.openecomp.dcae.controller.core.stream.DcaeStream; +import org.openecomp.dcae.controller.core.stream.DmaapStream; +import org.openecomp.dcae.controller.core.stream.StreamAuthentication; +import org.openecomp.dcae.controller.core.stream.StreamFactory; +import org.openecomp.dcae.controller.platform.controller.ControllerPackage; +import org.openecomp.dcae.controller.platform.controller.DcaeDataBus; +import org.openecomp.dcae.controller.platform.controller.DcaePlatformController; +import org.openecomp.dcae.controller.platform.controller.ServerRole; +import org.openecomp.dcae.controller.platform.servers.controller.logging.DcaeControllerMessageEnum; +import org.openecomp.dcae.controller.platform.servers.controller.logging.DcaeControllerOperationEnum; +import org.openecomp.dcae.controller.service.cdap.CdapService; +import org.openecomp.dcae.controller.service.cdap.CdapServiceInstance; +import org.openecomp.dcae.controller.service.docker.DockerService; +import org.openecomp.dcae.controller.service.docker.DockerServiceInstance; +import org.openecomp.dcae.controller.service.vm.VirtualMachineService; +import org.openecomp.dcae.controller.service.vm.VirtualMachineServiceInstance; +import org.openecomp.logger.EcompLogger; +import org.openecomp.ncomp.core.DeploymentStatus; +import org.openecomp.ncomp.core.NamedEntity; +import org.openecomp.ncomp.sirius.manager.BasicManagementServerProvider; +import org.openecomp.ncomp.sirius.manager.ISiriusServer; +import org.openecomp.ncomp.sirius.manager.ISwaggerHandler; +import org.openecomp.ncomp.sirius.manager.JavaHttpClient; +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.SwaggerUtils; +import org.openecomp.ncomp.utils.CryptoUtils; +import org.openecomp.ncomp.utils.PropertyUtil; +import org.openecomp.ncomp.webservice.utils.DateUtils; +import org.openecomp.ncomp.webservice.utils.JsonUtils; + +public class DcaeDcaePlatformControllerProvider extends BasicManagementServerProvider { + private static final Logger logger = Logger.getLogger(DcaeDcaePlatformControllerProvider.class); + static final EcompLogger ecomplogger = EcompLogger.getEcompLogger(); + DcaePlatformController o; + + public DcaeDcaePlatformControllerProvider(ISiriusServer controller, DcaePlatformController o) { + super(controller, o); + this.o = o; + } + + public void start() { + if (o.getCluster() == null) { + DcaeControllerFactory f3 = new DcaeControllerFactory(controller); + o.setCluster(f3.createControllerCluster()); + } + Thread t = new Thread("health checks") { + @Override + public void run() { + ecomplogger.setOperation(DcaeControllerOperationEnum.HEALTHCHECK); + while (true) { + try { + if (!controller.getServer().isSlave) { + ecomplogger.newRequestId(); + ecomplogger.recordAuditEventStart(); + for (DcaeService s : o.getServices()) { + try { + s.runHealthTests(); + } catch (Exception e) { + ecomplogger.warn(DcaeControllerMessageEnum.HEALTHCHECK_SERVICE_FAILED, s.getName()); + ManagementServerUtils.printStackTrace(e); + } + } + ecomplogger.recordAuditEventEnd(); + } + Thread.sleep(60000); // sleep 60 seconds + } catch (Exception e) { + ManagementServerUtils.printStackTrace(e); + logger.fatal("health checks: " + e); + try { + Thread.sleep(30000); + } catch (InterruptedException e1) { + } + } + } + } + }; + t.start(); + + Thread t2 = new Thread("policy polling") { + @Override + public void run() { + long frequency = 300000; // 5 minute default + try { + Properties props = PropertyUtil.getPropertiesFromClasspath("controller.properties"); + if (props.containsKey("policy.pollingFrequency")) { + frequency = Long.parseLong(props.getProperty("policy.pollingFrequency")); + } + } catch (Exception e) { + e.printStackTrace(); + } + ecomplogger.setOperation(DcaeControllerOperationEnum.POLICY_POLLING); + while (true) { + try { + System.out.println("PPPPPPPPPPP polling start"); + switch (o.getCluster().getRole()) { + case MASTER: + case UNKNOWN: + case STANDALONE: + ecomplogger.newRequestId(); + ecomplogger.recordAuditEventStart(); + System.out.println("PPPPPPPPPPP polling start"); + for (DcaeService s : o.getServices()) { + for (DcaeServiceInstance i : instances(s)) { + System.out.println("PPPPPPPPPPP updateObjectUsingPolicy list: " + s.getName() + "/" + i.getName()); + if (i.getStatus() != DeploymentStatus.DEPLOYED) + continue; + EList<DcaePolicyEntity> l = findPolicyEnabledObjects(i); + System.out.println("PPPPPPPPPPP updateObjectUsingPolicy list: " + l); + for (DcaePolicyEntity o2 : l) { + try { + System.out.println("PPPPPPPPPPP updateObjectUsingPolicy: " + o2); + updateObjectUsingPolicy(o2, s, i); + } catch (Exception e) { + ecomplogger.warn(DcaeControllerMessageEnum.POLICY_POLLING_FAILED, + ManagementServer.object2ref(o2), e.toString()); + ManagementServerUtils.printStackTrace(e); + } + } + } + } + ecomplogger.recordAuditEventEnd(); + break; + case SLAVE: + break; + } + System.out.println("PPPPPPPPPPP frequency: " + frequency); + Thread.sleep(frequency); // sleep 5 seconds + } catch (Exception e) { + ManagementServerUtils.printStackTrace(e); + logger.fatal("policy polling: " + e); + System.out.println("PPPPPPPPPPP error: " + e); + try { + Thread.sleep(30000); + } catch (InterruptedException e1) { + } + } + } + } + + }; + t2.start(); + + Thread t3 = new Thread("databus polling") { + @Override + public void run() { + ecomplogger.setOperation(DcaeControllerOperationEnum.DATABUS_POLLING); + while (true) { + try { + switch (o.getCluster().getRole()) { + case MASTER: + case UNKNOWN: + case STANDALONE: + ecomplogger.newRequestId(); + ecomplogger.recordAuditEventStart(); + try { + updateDatabusInformation(); + } catch (Exception e) { + ecomplogger.warn(DcaeControllerMessageEnum.DATABUS_POLLING_FAILED, e.toString()); + ManagementServerUtils.printStackTrace(e); + } + ecomplogger.recordAuditEventEnd(); + break; + case SLAVE: + break; + } + Thread.sleep(1 * 60000); // sleep 1 minutes + } catch (Exception e) { + ManagementServerUtils.printStackTrace(e); + logger.fatal("health checks: " + e); + try { + Thread.sleep(30000); + } catch (InterruptedException e1) { + } + } + } + } + + }; + t3.start(); + + } + + protected void updateDatabusInformation() { + if (o.getDatabus() == null) + return; + databusPoll(o.getDatabus()); + databusUpdateController(o.getDatabus()); + for (DatabusStream stream : o.getDatabus().getStreams()) { + try { + if (stream instanceof DatabusStreamFeed) { + DatabusStreamFeed feed = (DatabusStreamFeed) stream; + if (feed.getFeedName() == null) { + databusAddFeed(feed, o.getDatabus()); + } + } + if (stream instanceof DatabusStreamTopic) { + DatabusStreamTopic topic = (DatabusStreamTopic) stream; + if (topic.getTopicName() == null) { + databusAddTopic(topic); + } + } + } catch (Exception e) { + System.err.println("DATABUS ERROR:" + stream.getName() + " " + e); + e.printStackTrace(); + } + } + HashMap<DcaeServiceInstance, List<DmaapStream>> inputs = new HashMap<DcaeServiceInstance, List<DmaapStream>>(); + HashMap<DcaeServiceInstance, List<DmaapStream>> outputs = new HashMap<DcaeServiceInstance, List<DmaapStream>>(); + for (DatabusStream stream : o.getDatabus().getStreams()) { + // if (!stream.getName().startsWith("local:")) + // continue; + if (stream instanceof DatabusStreamFeed) { + DatabusStreamFeed feed = (DatabusStreamFeed) stream; + for (DatabusStreamFeedPublisher p : feed.getPublishers()) { + addStream(outputs, "file", "publish", p.getName(), p.getLocalStreamId(), p.getUsername(), + p.getUserpwd(), feed.getPublishURL(), "password"); + } + for (DatabusStreamFeedSubscriber s : feed.getSubscribers()) { + addStream(inputs, "file", "subscribe", s.getName(), s.getLocalStreamId(), s.getUsername(), + s.getUserpwd(), s.getDeliveryURL(), "password"); + } + } + if (stream instanceof DatabusStreamTopic) { + DatabusStreamTopic topic = (DatabusStreamTopic) stream; + for (DatabusStreamTopicClient p : topic.getClients()) { + // System.err.println("UPDATE: " + p.getName() + " " + + // p.getTopicURL()); + if (p.getAction().contains(DatabusStreamTopicAction.PUB)) + addStream(outputs, "message", "publish", p.getName(), p.getLocalStreamId(), p.getUsername(), + p.getUserpwd(), p.getTopicURL(), topic.getAuthenticationMethod().toString()); + else + addStream(inputs, "message", "subscribe", p.getName(), p.getLocalStreamId(), p.getUsername(), + p.getUserpwd(), p.getTopicURL(), topic.getAuthenticationMethod().toString()); + } + } + } + for (DcaeService s : o.getServices()) { + for (DcaeServiceInstance i : instances(s)) { + if (inputs.get(i) == null && outputs.get(i) == null) + continue; + String before = streamsHash(i); + i.getInputStreams().clear(); + if (inputs.get(i) != null) + i.getInputStreams().addAll(inputs.get(i)); + i.getOutputStreams().clear(); + if (outputs.get(i) != null) + i.getOutputStreams().addAll(outputs.get(i)); + String after = streamsHash(i); + if (i.getStatus() == DeploymentStatus.DEPLOYED && !before.equals(after)) { + s.pushManagerConfiguration(i.getName()); + } + } + } + } + + private String streamsHash(DcaeServiceInstance i) { + StringBuffer buf = new StringBuffer(); + for (DcaeStream s : i.getInputStreams()) { + buf.append(streamHash(s)).append("::"); + } + for (DcaeStream s : i.getOutputStreams()) { + buf.append(streamHash(s)).append("::"); + } + return buf.toString(); + } + + private Object streamHash(DcaeStream s) { + StringBuffer buf = new StringBuffer(); + if (s instanceof DmaapStream) { + DmaapStream ss = (DmaapStream) s; + buf.append(ss.getDmaapUrl()).append(":"); + buf.append(ss.getDmaapPassword()).append(":"); + buf.append(ss.getDmaapUserName()).append(":"); + buf.append(ss.getDmaapDataType()).append(":"); + } + return buf.toString(); + } + + private void databusUpdateController(DcaeDataBus databus) { + JavaHttpClient client = new JavaHttpClient("controller.properties", "databus"); + String drService = client.props.getProperty("databus.mr.service", "/services/vm-databus-dr-node"); + String mrService = client.props.getProperty("databus.mr.service", "/services/vm-databus-mr-node"); + Date time = new Date(); + HashMap<String, String> headers = new HashMap<String, String>(); + headers.put("Content-Type", "application/json"); + JSONObject json2 = new JSONObject(); + json2.put("dmaapName", client.props.get("databus.dmaapName")); + json2.put("drProvUrl", client.props.get("databus.drProvUrl")); + json2.put("version", "1"); + json2.put("topicNsRoot", "org.openecomp.dcae.dmaap"); + json2.put("bridgeAdminTopic", "DCAE_MM_AGENT"); + try { + client.httpJsonTransaction("/webapi/dmaap", "PUT", headers, json2); + System.err.println("DATABUS: dmaap: " + json2); + } catch (Exception e) { + System.err.println("DATABUS: dmaap: FAILED"); + } + for (DcaeLocation l : o.getLocations()) { + if (findNamed(databus.getLocations(), l.getName()) != null) + continue; + // Need to update Databus Controller. + JSONObject json = new JSONObject(); + json.put("dcaeLocationName", l.getName()); + json.put("dcaeLayer", l.getLocationType()); + client.httpJsonTransaction("/webapi/dcaeLocations", "POST", headers, json); + } + Subject s = controller.getServer().find(drService); + if (s == null || s.o == null) { + logger.warn("No vm-databus-dr-node service: " + drService); + } else { + VirtualMachineService drNodeService = (VirtualMachineService) s.o; + for (VirtualMachineServiceInstance i : drNodeService.getInstances()) { + for (DcaeBasicServer server : i.getServers()) { + boolean found = findNamed(databus.getDrNodes(), server.getName()) != null; + if (!found && i.getStatus() == DeploymentStatus.DEPLOYED) { + // Need to update Databus Controller. + JSONObject json = new JSONObject(); + json.put("hostName", server.getName()); + json.put("dcaeLocationName", i.getName()); + json.put("fqdn", server.getNetworks().get(0).getDnsName()); + client.httpJsonTransaction("/webapi/dr_nodes", "POST", headers, json); + System.err.println("DATABUS: add dr node: " + server.getName() + " " + time); + } + if (found && i.getStatus() != DeploymentStatus.DEPLOYED) { + client.httpJsonTransaction("/webapi/dr_nodes/" + server.getName(), "DELETE", headers, null); + System.err.println("DATABUS: delete dr node: " + server.getName() + " " + time); + } + } + } + } + s = controller.getServer().find(mrService); + if (s == null || s.o == null) { + logger.error("No vm-databus-mr-node service: " + mrService); + } else { + VirtualMachineService mrNodeService = (VirtualMachineService) s.o; + for (VirtualMachineServiceInstance i : mrNodeService.getInstances()) { + boolean found = findNamed(databus.getMrClusters(), i.getName()) != null; + if (!found && i.getStatus() == DeploymentStatus.DEPLOYED) { + // Need to update Databus Controller. + JSONObject json = new JSONObject(); + json.put("dcaeLocationName", i.getName()); + JSONArray a = new JSONArray(); + json.put("hosts", a); + for (DcaeBasicServer server : i.getServers()) { + a.put(server.getNetworks().get(0).getDnsName()); + } + json.put("fqdn", i.getServiceFqdn()); + client.httpJsonTransaction("/webapi/mr_clusters", "POST", headers, json); + System.err.println("DATABUS: add mr cluster: " + i.getName() + " " + time); + } + if (found && i.getStatus() != DeploymentStatus.DEPLOYED) { + // TODO + client.httpJsonTransaction("/webapi/mr_clusters/" + i.getName(), "DELETE", headers, null); + System.err.println("DATABUS: delete mr cluster: " + i.getName() + " " + time); + } + } + } + } + + private <T extends NamedEntity> T findNamed(EList<? extends T> l, String name) { + for (T t : l) { + if (t.getName() != null && t.getName().equals(name)) + return t; + } + return null; + } + + private void addStream(HashMap<DcaeServiceInstance, List<DmaapStream>> m, String type, String action, String name, + String id, String username, String userpwd, String url, String authMethod) { + // name is service:locationName + String a[] = name.split(":"); + if (a.length != 2) + return; + String path = "/services/" + a[0]; + Subject s = controller.getServer().find(path); + if (s == null || s.o == null) + return; + DcaeService s1 = (DcaeService) s.o; + for (DcaeServiceInstance i : instances(s1)) { + if (!a[1].equals(location(i))) + continue; + DmaapStream d = StreamFactory.eINSTANCE.createDmaapStream(); + d.setName(id); + d.setDmaapAuthMethod(authMethod); + d.setDmaapAction(action); + d.setDmaapDataType(type); + d.setDmaapUrl(url); + d.setDmaapUserName(username); + d.setDmaapPassword(userpwd); + // System.err.println("UPDATE: " + d); + List<DmaapStream> l = m.get(i); + if (l == null) { + l = new ArrayList<DmaapStream>(); + m.put(i, l); + } + l.add(d); + } + } + + static int numberOfErrors = 0; + static int tooMany = 40; + + // XX remove static + + private void databusAddFeed(DatabusStreamFeed feed, DcaeDataBus bus) { + if (feed.getFeedName() != null && !feed.getFeedName().equals("")) + return; + if (numberOfErrors > tooMany) { + logger.warn("Too many added"); + feed.setFeedName("FAILED TOO MANY"); + return; + } + try { + JavaHttpClient client = new JavaHttpClient("controller.properties", "databus"); + HashMap<String, String> headers = new HashMap<String, String>(); + headers.put("Content-Type", "application/json"); + JSONObject json = ManagementServer.ecore2json(feed, 100, feed.eClass(), true); + System.err.println("FEED0: " + feed.getName() + " " + json.toString(2)); + if (feed.getPublishers().size() == 0) { + // Add a generic publisher + DatabusStreamFeedPublisher p = StreamFactory.eINSTANCE.createDatabusStreamFeedPublisher(); + p.setName("auto-add"); + feed.getPublishers().add(p); + } + if (feed.getSubscribers().size() == 0) + return; + for (DatabusStreamFeedSubscriber s : feed.getSubscribers()) { + if (s.getOtherFeedName() == null) { + continue; + } + DatabusStreamFeed feed2 = findFeed(bus, s.getOtherFeedName()); + if (feed2 == null) + return; + System.err.println("FEED X1: " + s.getOtherFeedName() + " " + feed2.getName()); + System.err.println("FEED X2: " + feed2.getPublishURL() + " " + feed2.getPublishers().size()); + if (feed2.getPublishURL() == null || feed2.getPublishers().size() == 0) + return; + s.setDeliveryURL(feed2.getPublishURL()); + DatabusStreamFeedPublisher p = feed2.getPublishers().get(0); + s.setUsername(p.getUsername()); + s.setUserpwd(p.getUserpwd()); + System.err.println("FEED X2: " + s.getDeliveryURL() + " " + s.getUserpwd()); + } + json = ManagementServer.ecore2json(feed, 100, feed.eClass(), true); + String feedName = feed.getName() + ":" + new Date().getTime(); + json.put("feedVersion", "1.0"); + json.put("feedName", feedName); + json.put("owner", "controller"); + JSONArray a = new JSONArray(); + JSONObject pub = json.getJSONObject("publishers"); + for (Iterator<String> i = pub.keys(); i.hasNext();) { + String k = i.next(); + JSONObject json1 = pub.getJSONObject(k); + if (!k.startsWith("external")) { + String user = "dcae"; + if (json1.has("dcaeLocationName")) + user = json1.getString("dcaeLocationName"); + json1.put("username", user); + json1.put("userpwd", password()); + } else { + if (json1.has("userpwd")) + json1.put("userpwd", JavaHttpClient.decryptPassword(json1.getString("userpwd"))); + } + if (json1.has("localStreamId")) + json1.remove("localStreamId"); + if (json1.has("feedId")) + json1.remove("feedId"); + if (json1.has("pubId")) + json1.remove("pubId"); + if (json1.has("status")) + json1.remove("status"); + a.put(json1); + } + json.put("pubs", a); + json.remove("publishers"); + JSONArray a1 = new JSONArray(); + JSONObject sub = json.getJSONObject("subscribers"); + for (Iterator<String> i = sub.keys(); i.hasNext();) { + String k = i.next(); + JSONObject json1 = sub.getJSONObject(k); + if (!k.startsWith("external") && !k.startsWith("forward")) { + String user = "dcae"; + if (json1.has("dcaeLocationName")) + user = json1.getString("dcaeLocationName"); + json1.put("username", user); + json1.put("userpwd", password()); + } else { + if (json1.has("userpwd")) + json1.put("userpwd", JavaHttpClient.decryptPassword(json1.getString("userpwd"))); + } + if (json1.has("localStreamId")) + json1.remove("localStreamId"); + if (json1.has("otherFeedName")) + json1.remove("otherFeedName"); + if (json1.has("suspended")) + json1.remove("suspended"); + if (json1.has("use100")) + json1.remove("use100"); + if (json1.has("feedId")) + json1.remove("feedId"); + if (json1.has("logURL")) + json1.remove("logURL"); + if (json1.has("owner")) + json1.remove("owner"); + if (json1.has("subId")) + json1.remove("subId"); + a1.put(json1); + } + json.put("subs", a1); + json.remove("subscribers"); + System.err.println("FEED1: " + json.toString(2)); + JSONObject res = client.httpJsonTransaction("/webapi/feeds", "POST", headers, json); + if (res == null) { + numberOfErrors++; + feed.setFeedName("FAILED"); + logger.warn("unable to create feed: " + feed.getName() + " " + json.toString(2)); + return; + } + System.err.println("FEED2: " + res.toString(2)); + JSONArray aa1 = res.getJSONArray("pubs"); + JSONObject pub1 = new JSONObject(); + for (int i = 0; i < aa1.length() && i < feed.getPublishers().size(); i++) { + pub1.put(feed.getPublishers().get(i).getName(), aa1.getJSONObject(i)); + } + res.put("publishers", pub1); + res.remove("pubs"); + JSONArray aa2 = res.getJSONArray("subs"); + JSONObject sub1 = new JSONObject(); + for (int i = 0; i < aa2.length(); i++) { + if (aa2.get(i) instanceof JSONObject) + sub1.put(feed.getSubscribers().get(i).getName(), aa2.getJSONObject(i)); + else { + JSONObject j2 = new JSONObject(); + j2.put("username", "NULL"); + sub1.put(feed.getSubscribers().get(i).getName(), j2); + } + } + res.put("subscribers", sub1); + res.remove("subs"); + System.err.println("FEED3: " + res.toString(2)); + // XX use second + // ManagementServer s = server; + ManagementServer s = controller.getServer(); + DatabusStreamFeed feed1 = (DatabusStreamFeed) s.json2ecore(feed.eClass(), res); + System.err.println("FEED4: " + ManagementServer.ecore2json(feed1, 100, feed.eClass(), true).toString(2)); + encryptPasswords(feed1); + ManagementServer.merge(feed, feed1, res, true, null); + if (feed.getFeedName() == null) { + feed.setFeedName("FAILED with no name"); + } + System.err.println("FEED5: " + ManagementServer.ecore2json(feed, 100, feed.eClass(), true).toString(2)); + } catch (Exception e) { + numberOfErrors++; + feed.setFeedName("ERROR: " + e.toString()); + } + } + + private void encryptPasswords(DatabusStreamFeed feed) { + for (DatabusStreamFeedPublisher p : feed.getPublishers()) { + if (p.getUserpwd().startsWith("rsa:")) + continue; + p.setUserpwd(encryptPassword(p.getUserpwd())); + } + for (DatabusStreamFeedSubscriber s : feed.getSubscribers()) { + if (s.getUserpwd().startsWith("rsa:")) + continue; + s.setUserpwd(encryptPassword(s.getUserpwd())); + } + } + + private String encryptPassword(String v) { + if (publicKey == null) + publicKey = CryptoUtils.getKey("config/server.public"); + return "rsa:" + CryptoUtils.encryptPublic(publicKey, v); + } + + private static DatabusStreamFeed findFeed(DcaeDataBus bus, String otherFeedName) { + for (DatabusStream s : bus.getStreams()) { + if (s instanceof DatabusStreamFeed) { + DatabusStreamFeed f = (DatabusStreamFeed) s; + if (f.getName().equals(otherFeedName)) + return f; + } + } + return null; + } + + // XX remove static + @SuppressWarnings("unused") + private void databusAddTopic(DatabusStreamTopic topic) { + if (topic.getTopicName() != null) + return; + if (topic.getClients().size() == 0) + return; + String topicName = topic.getName().replace("topic:", ""); + if (topic.getAuthenticationMethod() == StreamAuthentication.NONE) { + for (DatabusStreamTopicClient c : topic.getClients()) { + DatabusMessageRouterCluster m = findNamed(o.getDatabus().getMrClusters(), c.getDcaeLocationName()); + if (m == null) + return; + c.setFqtn("unauthenticated." + topicName); + String protocol = m.getTopicProtocol() + "://"; + // TODO fix OPENECOMP hack + // c.setTopicURL(protocol + m.getServiceFqdn() + ":" + + // m.getTopicPort() + "/" + c.getFqtn()); + c.setTopicURL("http://" + m.getServiceFqdn() + ":" + "3904" + "/" + c.getFqtn()); + } + topic.setTopicName(topicName); + return; + } + if (numberOfErrors > tooMany) { + logger.warn("Too many added"); + topic.setTopicName("FAILED TOO MANY"); + return; + } + for (DatabusStreamTopicClient p : topic.getClients()) + p.setTopicURL(null); + try { + JavaHttpClient client = new JavaHttpClient("controller.properties", "databus"); + HashMap<String, String> headers = new HashMap<String, String>(); + headers.put("Content-Type", "application/json"); + JSONObject json = ManagementServer.ecore2json(topic, 100, topic.eClass(), true); + if (topic.getFqtn() != null) { + client.httpJsonTransaction("/webapi/topics/" + topic.getFqtn(), "DELETE", headers, null); + System.err.println("TOPIC0: delete existing topic: " + topicName); + } else + System.err.println("TOPIC0: new topic: " + topicName); + json.put("topicName", topicName); + json.put("owner", "controller"); + json.put("txenabled", false); + JSONArray a = new JSONArray(); + JSONObject clients = json.getJSONObject("clients"); + for (Iterator<String> i = clients.keys(); i.hasNext();) { + String k = i.next(); + JSONObject json1 = clients.getJSONObject(k); + if (json1.has("localStreamId")) + json1.remove("localStreamId"); + if (json1.has("username")) + json1.remove("username"); + if (json1.has("userpwd")) + json1.remove("userpwd"); + if (json1.has("fqtn")) + json1.remove("fqtn"); + if (json1.has("mrClientId")) + json1.remove("mrClientId"); + a.put(json1); + } + json.put("clients", a); + System.err.println("TOPIC1: " + json.toString(2)); + JSONObject res; + try { + res = client.httpJsonTransaction("/webapi/topics", "POST", headers, json); + } catch (Exception e) { + if (e.getMessage().contains("topic already exists")) { + String s = e.getMessage(); + int i = s.indexOf("topic already exists"); + s = s.substring(i + "topic already exists: ".length()).replace("\"}", ""); + topic.setFqtn(s); + System.err.println("TOPIC2: topic already exists without FQTN"); + return; + } + throw e; + } + if (res == null) { + numberOfErrors++; + logger.warn("unable to create topic: " + topic.getName() + " " + json.toString(2)); + return; + } + System.err.println("TOPIC2: " + res.toString(2)); + JSONArray aa1 = res.getJSONArray("clients"); + JSONObject clients1 = new JSONObject(); + for (int i = 0; i < aa1.length() && i < topic.getClients().size(); i++) { + clients1.put(topic.getClients().get(i).getName(), aa1.getJSONObject(i)); + } + res.put("clients", clients1); + System.err.println("TOPIC3: " + res.toString(2)); + // XX use second + // ManagementServer s = server; + ManagementServer s = controller.getServer(); + DatabusStreamTopic topic1 = (DatabusStreamTopic) s.json2ecore(topic.eClass(), res); + System.err.println("TOPIC4: " + ManagementServer.ecore2json(topic1, 100, topic.eClass(), true).toString(2)); + ManagementServer.merge(topic, topic1, res, true, null); + if (topic.getTopicName() == null) { + topic.setTopicName("FAILED with no name"); + } + System.err.println("TOPIC5: " + ManagementServer.ecore2json(topic, 100, topic.eClass(), true).toString(2)); + } catch (Exception e) { + numberOfErrors++; + topic.setTopicName("ERROR: " + e.toString()); + } + } + + private static String password() { + return new BigInteger(130, new SecureRandom()).toString(32); + } + + static ManagementServer server; + + public static void main(String[] args) throws IOException { + server = new ManagementServer(); + JSONObject json = JsonUtils + .file2json("CONFIG/controller-gen/resources/databus.json"); + DcaeDataBus d = (DcaeDataBus) server.json2ecore(ControllerPackage.eINSTANCE.getDcaeDataBus(), json); + databusPoll(d); + for (DatabusStream stream : d.getStreams()) { + if (stream instanceof DatabusStreamFeed) { + DatabusStreamFeed feed = (DatabusStreamFeed) stream; + if (feed.getFeedName() == null) { + // XX comment out + // databusAddFeed(feed,d); + } + } + if (stream instanceof DatabusStreamTopic) { + DatabusStreamTopic feed = (DatabusStreamTopic) stream; + if (feed.getTopicName() == null) { + // XX comment out + // databusAddTopic(feed); + } + } + } + System.out.println("FEED5: " + ManagementServer.ecore2json(d, 100, null, true).toString(2)); + // updateDatabusInformation(); + } + + private static void databusPoll(DcaeDataBus d) { + JavaHttpClient client = new JavaHttpClient("controller.properties", "databus"); + HashMap<String, String> headers = new HashMap<String, String>(); + headers.put("Content-Type", "application/json"); + // locations + JSONObject res1 = client.httpJsonTransaction("/webapi/dcaeLocations", "GET", headers, null); + // System.err.println("DATABUS0: locations" + res1.toString(2)); + databusJson2locations(res1, d); + // mr_clusters + JSONObject res2 = client.httpJsonTransaction("/webapi/mr_clusters", "GET", headers, null); + // System.err.println("DATABUS0: mr_clusters" + res2.toString(2)); + databusJson2mrClusters(res2, d); + // dr_nodes + JSONObject res3 = client.httpJsonTransaction("/webapi/dr_nodes", "GET", headers, null); + // System.err.println("DATABUS0: dr_nodes" + res3.toString(2)); + databusJson2drNodes(res3, d); + + } + + private static void databusJson2drNodes(JSONObject json, DcaeDataBus d) { + JSONArray a = json.getJSONArray("$list"); + List<DatabusDataRouterNode> l = new ArrayList<DatabusDataRouterNode>(); + for (int i = 0; i < a.length(); i++) { + JSONObject locJson = a.getJSONObject(i); + DatabusDataRouterNode drNode = StreamFactory.eINSTANCE.createDatabusDataRouterNode(); + drNode.setName(locJson.getString("hostName")); + drNode.setVersion(getString(locJson, "version")); + drNode.setHostFqdn(getString(locJson, "fqdn")); + drNode.setDcaeLocationName(getString(locJson, "dcaeLocationName")); + databusUpdateEntity(drNode, locJson); + l.add(drNode); + } + d.getDrNodes().clear(); + d.getDrNodes().addAll(l); + } + + private static void databusJson2mrClusters(JSONObject json, DcaeDataBus d) { + JSONArray a = json.getJSONArray("$list"); + List<DatabusMessageRouterCluster> l = new ArrayList<DatabusMessageRouterCluster>(); + for (int i = 0; i < a.length(); i++) { + JSONObject locJson = a.getJSONObject(i); + DatabusMessageRouterCluster c = StreamFactory.eINSTANCE.createDatabusMessageRouterCluster(); + c.setName(locJson.getString("dcaeLocationName")); + c.setServiceFqdn(getString(locJson, "fqdn")); + c.setDcaeLocationName(locJson.getString("dcaeLocationName")); + JSONArray aa = locJson.getJSONArray("hosts"); + for (int j = 0; j < aa.length(); j++) { + c.getHostFqdn().add(aa.getString(j)); + } + c.setTopicPort(getString(locJson, "topicPort")); + c.setTopicProtocol(getString(locJson, "topicProtocol")); + databusUpdateEntity(c, locJson); + l.add(c); + } + d.getMrClusters().clear(); + d.getMrClusters().addAll(l); + } + + private static String getString(JSONObject json, String key) { + return json.has(key) ? json.getString(key) : null; + } + + private static void databusJson2locations(JSONObject json, DcaeDataBus d) { + JSONArray a = json.getJSONArray("$list"); + List<DatabusLocation> l = new ArrayList<DatabusLocation>(); + for (int i = 0; i < a.length(); i++) { + JSONObject locJson = a.getJSONObject(i); + DatabusLocation loc = StreamFactory.eINSTANCE.createDatabusLocation(); + loc.setName(locJson.getString("dcaeLocationName")); + loc.setDcaeLayer(getString(locJson, "dcaeLayer")); + databusUpdateEntity(loc, locJson); + l.add(loc); + } + d.getLocations().clear(); + d.getLocations().addAll(l); + } + + private static void databusUpdateEntity(DatabusEntity e, JSONObject json) { + e.setStatus(getString(json, "status")); + e.setLastModified(json.has("lastMod") ? DateUtils.dateFromString(json.getString("lastMod")) : null); + e.setType(getString(json, "type")); + } + + private void updateObjectUsingPolicy(DcaePolicyEntity o2, DcaeService s, DcaeServiceInstance i) { + if (location(i) == null) + return; + System.out.println("PPPPPPPPPPP START: "); + JavaHttpClient client = new JavaHttpClient("controller.properties", "policy"); + if (client.getBaseAddress() == null) { + logger.warn("No Policy Endpoint configured"); + return; + } + HashMap<String, String> headers = new HashMap<String, String>(); + JSONObject json = new JSONObject(); + headers.put("ClientAuth", "cHl0aG9uOnRlc3Q="); + headers.put("Environment", "TEST"); + JSONObject json2 = new JSONObject(); + // json.put("configAttributes", json2); + String uuid = ManagementServer.object2ref(o2).toLowerCase(); + for (Object k : client.props.keySet()) { + String key = (String) k; + if (key.startsWith("policy.substitution.")) { + uuid = uuid.replace(key.substring(20), client.props.getProperty(key)); + } + } + json2.put("uuid", uuid); + json.put("policyName", ".*"); + JSONObject res = client.httpJsonTransaction("/PyPDPServer/getConfig", "POST", headers, json); + System.out.println("PPPPPPPPPPP 0: " + uuid); + JSONArray a = res.getJSONArray("$list"); + for (int j = 0; j < a.length(); j++) { + JSONObject c1 = a.getJSONObject(j); +// if (c1.has("matchingConditions") && c1.getJSONObject("matchingConditions").has("ECOMPName")) { +// if (c1.getJSONObject("matchingConditions").getString("ECOMPName").equals("DCAE")) +// continue; +// } + System.out.println("PPPPPPPPPPP 1: " + c1.toString(2)); + JSONObject newConfig; + try { + newConfig = new JSONObject(c1.getString("config")); + } catch (Exception e) { + System.out.println("PPPPPPPPPPP 1.1: " + c1.toString(2)); + continue; + } + System.out.println("PPPPPPPPPPP 2: " + newConfig.toString(2) + " uuid:" + newConfig.get("uuid")); + if (!uuid.equals(newConfig.getString("uuid").toLowerCase())) + continue; + JSONObject content = new JSONObject(newConfig.getString("content")); + System.out.println("PPPPPPPPPPP 3: " + content.toString(2)); + content.put("policyName", newConfig.getString("policyName")); + content.put("policyDescription", newConfig.getString("description")); + content.put("policyConfigName", newConfig.getString("configName")); + content.put("policyTemplateVersion", newConfig.getString("templateVersion")); + content.put("policyVersion", newConfig.getString("version")); + content.put("policyPriority", newConfig.getString("priority")); + content.put("policyScope", newConfig.getString("policyScope")); + System.out.println("PPPPPPPPPPP 4: " + content.toString(2)); + ManagementServer server = controller.getServer(); + EObject oo = server.json2ecore(o2.eClass(), content); + // System.out.println("PPPPPPPPPPP 4_1: " + + // ManagementServer.ecore2json(oo, 1000, null, true).toString(2)); + JSONObject before = cleanJson(o2); + ManagementServer.merge(o2, oo, null, true, null); + JSONObject after = cleanJson(o2); + ManagementServer.ecore2json(o2, 1000, null, true); + if (!before.toString(2).equals(after.toString(2))) { + System.out.println("PPPPPPPPPPP configuration change 5: " + ManagementServer.object2ref(i)); + System.out.println("PPPPPPPPPPP before: " + before.toString(2)); + System.out.println("PPPPPPPPPPP after: " + after.toString(2)); + s.pushManagerConfiguration(i.getName()); + } + return; + } + System.out.println("PPPPPPPPPPP ERROR no policy found: " + uuid); + } + + private JSONObject cleanJson(EObject o2) { + JSONObject json = ManagementServer.ecore2json(o2, 1000, null, true); + removeLastChanged(json); + return json; + } + + private void removeLastChanged(Object o) { + if (o instanceof JSONObject) { + JSONObject json = (JSONObject) o; + json.remove("lastChanged"); + for (Iterator<String> i = json.keys(); i.hasNext();) { + String key = i.next(); + removeLastChanged(json.get(key)); + } + } + if (o instanceof JSONArray) { + JSONArray a = (JSONArray) o; + for (int i = 0; i < a.length(); i++) { + removeLastChanged(a.get(i)); + } + } + } + + private String location(DcaeServiceInstance i) { + if (i instanceof VirtualMachineServiceInstance) { + VirtualMachineServiceInstance i1 = (VirtualMachineServiceInstance) i; + if (i1.getLocation() == null) + return null; + return i1.getLocation().getName(); + } + if (i instanceof CdapServiceInstance) { + CdapServiceInstance i1 = (CdapServiceInstance) i; + if (i1.getClusterService() == null) + return null; + return location(i1.getClusterService()); + } + if (i instanceof DockerServiceInstance) { + DockerServiceInstance i1 = (DockerServiceInstance) i; + if (i1.getHostService() == null) + return null; + return location(i1.getHostService()); + } + throw new RuntimeException("unknown service instance: " + i); + } + + protected EList<? extends DcaeServiceInstance> instances(DcaeService s) { + if (s instanceof VirtualMachineService) { + VirtualMachineService s1 = (VirtualMachineService) s; + return s1.getInstances(); + } + if (s instanceof CdapService) { + CdapService s1 = (CdapService) s; + return s1.getInstances(); + } + if (s instanceof DockerService) { + DockerService s1 = (DockerService) s; + return s1.getInstances(); + } + throw new RuntimeException("unknown service: " + s); + } + + private EList<DcaePolicyEntity> findPolicyEnabledObjects(EObject o2) { + EList<DcaePolicyEntity> res = new BasicEList<DcaePolicyEntity>(); + findPolicyEnabledObjects(o2, res); + return res; + } + + private void findPolicyEnabledObjects(EObject o2, EList<DcaePolicyEntity> res) { + if (o2 == null) + return; + if (o2 instanceof DcaePolicyEntity) { + res.add((DcaePolicyEntity) o2); + } + for (EReference ref : o2.eClass().getEAllContainments()) { + if (ref.isMany()) { + @SuppressWarnings("unchecked") + EList<EObject> l = (EList<EObject>) o2.eGet(ref); + for (EObject o3 : l) { + findPolicyEnabledObjects(o3, res); + } + } else + findPolicyEnabledObjects((EObject) o2.eGet(ref), res); + } + } + + public void deployDescriptor(String name) { + runCmd("bin/dcae-controller.sh deploy-descriptor --name " + name); + } + + private void runCmd(String cmd) { + Runtime run = Runtime.getRuntime(); + Process pr; + try { + logger.info("running: " + cmd); + pr = run.exec(cmd); + int status = pr.waitFor(); + logger.info("done: " + cmd); + BufferedReader buf = new BufferedReader(new InputStreamReader(pr.getInputStream())); + String line = ""; + while ((line = buf.readLine()) != null) { + logger.info("output: " + line); + } + buf = new BufferedReader(new InputStreamReader(pr.getErrorStream())); + while ((line = buf.readLine()) != null) { + System.err.println(line); + logger.warn("error: " + line); + } + if (status != 0) { + throw new RuntimeException("command failed: " + cmd); + } + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public Object handleJson(String userName, String action, String resourcePath, JSONObject json, JSONObject context) { + System.err.println("XXXXXX handleJson: " + action + " " + resourcePath + " " + context); + switch ((String) context.get("path")) { + case "/test": + if (o.getCluster().getRole() == ServerRole.MASTER) { + return new JSONObject("{ status: 'OKAY'}"); + } + throw new RuntimeException("Not Master Controller"); + case "/swagger": + return controller.getServer().getSwaggerJson(); + } + System.err.println("XXXXXXX: request not handled: path=" + resourcePath + " action=" + action + " json=" + + ((json != null) ? json.toString(2) : "NULL") + " context=" + + ((context != null) ? context.toString(2) : "NULL")); + return null; + + } + + public Object handleBinary(String userName, String action, String resourcePath, InputStream in) { + // TODO Auto-generated method stub + return null; + } + + public void refreshDataBus(String nameMatch) { + System.err.println("BBBBBBBBB: numberOfErrors=" + numberOfErrors + " tooMany=" + tooMany + " nameMatch=" + + nameMatch); + numberOfErrors = 0; + for (DatabusStream s : o.getDatabus().getStreams()) { + if (nameMatch != null && !s.getName().matches(nameMatch)) + continue; + if (s instanceof DatabusStreamFeed) { + DatabusStreamFeed f = (DatabusStreamFeed) s; + if (f.getFeedName() == null) + continue; + System.err.println("BBBBBBBBB: feed change to null " + ManagementServer.object2ref(s) + " " + + f.getFeedName()); + f.setFeedName(null); + for (DatabusStreamFeedPublisher c : f.getPublishers()) { + c.setFeedId(null); + c.setPubId(null); + c.setStatus(null); + } + for (DatabusStreamFeedSubscriber c : f.getSubscribers()) { + c.setFeedId(null); + c.setSubId(null); + c.setOwner(null); + c.setLogURL(null); + } + } + if (s instanceof DatabusStreamTopic) { + DatabusStreamTopic t = (DatabusStreamTopic) s; + if (t.getTopicName() == null) + continue; + System.err.println("BBBBBBBBB: topic change to null " + ManagementServer.object2ref(s) + " " + + t.getTopicName()); + t.setTopicName(null); + for (DatabusStreamTopicClient c : t.getClients()) { + c.setTopicURL(null); + c.setMrClientId(null); + c.setFqtn(null); + } + } + } + } + + @SuppressWarnings("unused") + private String privateKey = CryptoUtils.getKey("config/server.private"); + private String publicKey = null; + + public void updateSwagger(String path, SwaggerUtils swagger) { + swagger.addTag(path, "DCAE Controller API"); + swagger.addTag(path + "/configuration", "Server Basic Configuration"); + swagger.addTag(path + "/cluster", "Cluster Configuration"); + if (o.getOpenstack() instanceof ISwaggerHandler) { + ISwaggerHandler handler = (ISwaggerHandler) o.getOpenstack(); + handler.updateSwagger(path + "/openstack", swagger); + } + swagger.addTag(path + "/locations", "DCAE Locations Configuration"); + swagger.addTag(path + "/databus", "DataBus Configuration"); + swagger.addTag(path + "/services", "DCAE Services"); + for (DcaeService s : o.getServices()) { + String path1 = path + "/services/" + s.getName(); + swagger.addTag(path1, ""); + if (instances(s).size() > 0) { + // Use instance as a API guide to handle inheritance. + // swagger.autoAddApi(path1 + "/instances/{instanceName}", + // instances(s).get(0)); + } + // swagger.autoAddApi(path1, s); + } + DcaeService s = o.getServices().get(o.getServices().size() - 1); + swagger.autoAddApi(path + "/services/" + s.getName() + "/instances/{instanceName}", instances(s).get(0)); + // Add missing automatically + + swagger.autoAdd(path, o.eClass(), 1, new ArrayList<String>()); + } +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/servers/controller/gui/DcaeGuiClientApiProvider.java b/dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/servers/controller/gui/DcaeGuiClientApiProvider.java new file mode 100644 index 0000000..ca6d6f4 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/java/org/openecomp/dcae/controller/platform/servers/controller/gui/DcaeGuiClientApiProvider.java @@ -0,0 +1,83 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +// Autogenerated +// Do not edit. No need to extend this class. +package org.openecomp.dcae.controller.platform.servers.controller.gui; + + + + + +import java.io.InputStream; + +import org.openecomp.ncomp.sirius.manager.IRequestHandler; +import org.openecomp.ncomp.sirius.manager.ISiriusPlugin; +import org.openecomp.ncomp.sirius.manager.ISiriusServer; +import org.openecomp.ncomp.sirius.function.FunctionUtils; + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; +import org.json.JSONObject; + + + +import org.openecomp.ncomp.sirius.gui.tools.*; + + +import org.openecomp.ncomp.gwt.siriusportal.model.*; + + +import org.openecomp.ncomp.sirius.manager.Subject; + + +import org.openecomp.ncomp.sirius.manager.ManagementServer; + + +import org.openecomp.ncomp.sirius.manager.server.AbstractManagementServer; + + +import org.openecomp.ncomp.sirius.manager.BasicGuiClientApiProvider; + +import org.openecomp.ncomp.gwt.siriusportal.model.impl.GuiClientApiImpl; +import org.openecomp.ncomp.gwt.siriusportal.model.GuiClientApi; + + +public class DcaeGuiClientApiProvider extends BasicGuiClientApiProvider { + private static final Logger logger = Logger.getLogger(DcaeGuiClientApiProvider.class); + GuiClientApi o; + + public DcaeGuiClientApiProvider(ISiriusServer controller, GuiClientApi o) { + super(controller, o); + this.o = o; + } + + + + + + public static void ecoreSetup() { + // TODO Auto-generated method stub + + } + + +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/resources/DcaeController.yaml b/dcae-controller-core/dcae-controller-platform-server/src/main/resources/DcaeController.yaml new file mode 100644 index 0000000..120d5ad --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/resources/DcaeController.yaml @@ -0,0 +1,45 @@ +operations: + HEALTHCHECK: + description: Heath Check for all DCAE service instances. + POLICY_POLLING: + description: Polling of new configuration from ECOMP Policy for all DCAE service instances. + DATABUS_POLLING: + description: Polling of new configuration from DCAE Data Bus Controller. + CLUSTER_DATA_REPLICATION: + description: Data replication from master to slave controllers. +messages: + HEALTHCHECK_SERVICE_FAILED: + errorCode: DCAE-CONTROLLER-HEALTHCHECK-SERVICE-FAILED-5001W + messageFormat: '{0}' + parameters: + service-name: + description: Name of Service for which the health check fails. + resolution: Contact Tier 4. This is a software bug. + description: Heath Check on the service level fails. + POLICY_POLLING_FAILED: + errorCode: DCAE-CONTROLLER-POLICY-POLLING-FAILED-5001W + messageFormat: '{0} {1}' + parameters: + object-path: + description: Object resource path for which the policy polling fails. + exception: + description: Exception that happened. + resolution: Contact Tier 4. This is a software bug. + description: Police Polling on the service level fails. + DATABUS_POLLING_FAILED: + errorCode: DCAE-CONTROLLER-DATABUS-POLLING-FAILED-5001W + messageFormat: '{0}' + parameters: + exception: + description: Exception that happened. + resolution: Contact Tier 4. This is a software bug. + description: Databus Polling on the service level fails. + + CLUSTER_DATA_REPLICATION_FAILED: + errorCode: DCAE-CONTROLLER-CLUSTER_DATA_REPLICATION-FAILED-5001W + messageFormat: '{0}' + parameters: + exception: + description: Exception that happened. + resolution: Contact Tier 4. This is a software bug. + description: Data Replication fails.
\ No newline at end of file diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server-gen/bin/controller-platform-server-controller b/dcae-controller-core/dcae-controller-platform-server/src/main/server-gen/bin/controller-platform-server-controller new file mode 100644 index 0000000..4f6f870 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server-gen/bin/controller-platform-server-controller @@ -0,0 +1,138 @@ +#!/bin/bash + +# setup env if needed. java 6 required +## JAVA_HOME= + +############################## DO NOT EDIT BELOW ########################## + +SNAME="Dcae Controller" +PNAME=controller-platform-server-controller +CLASS=org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerServer + +############################## COMMON BELOW ########################## + +check_status () +{ + if [ -f "${_PIDFILE}" ]; then + _PID=`cat "${_PIDFILE}"` + check_status_of_pid $_PID + else + _STATUS="$SNAME (no pidfile) is NOT running" + _RUNNING=0 + fi +} + + +check_status_of_pid () +{ + if [ -n "$1" ] && kill -0 $1 2>/dev/null ; then + _STATUS="$SNAME (pid $1) is running" + _RUNNING=1 + else + _STATUS="$SNAME (pid $1) is NOT running" + _RUNNING=0 + fi +} + + +check_status_of_pid () +{ + if [ -n "$1" ] && kill -0 $1 2>/dev/null ; then + _STATUS="$SNAME (pid $1) is running" + _RUNNING=1 + else + _STATUS="$SNAME (pid $1) is NOT running" + _RUNNING=0 + fi +} + +remove_pid_file () +{ + if [ -f "${_PIDFILE}" ]; then + rm "${_PIDFILE}" + fi +} + + +_DIR=`dirname "$0"` +_DIR=`dirname "$_DIR"` + +_PIDFILE=$_DIR/PID + +CMD=$1 +shift + +check_status + +CP=$(find $_DIR/lib/*/* -name \*.jar 2>/dev/null | xargs -I X printf ":%s" X) + +JVMARGS=$(grep 'server.jvmargs' $_DIR/config/controller.properties | sed -e 's/.*=//') + +case $CMD in + status) + echo $_STATUS + exit 0 + ;; + console) + $GROOVY_HOME/bin/groovysh -cp $_DIR/config:$_DIR/lib:$_DIR/lib/\*:$CP + ;; + run) + $JAVA_HOME/bin/java -cp $_DIR/config:$_DIR/lib:$_DIR/lib/\*:$CP "$@" + ;; + groovy) + $GROOVY_HOME/bin/groovy -cp $_DIR/config:$_DIR/lib:$_DIR/lib/\*:$CP "$@" + ;; + start) + if [ "$_RUNNING" = "1" ]; then + echo $_STATUS + exit 0 + fi + mkdir -p $_DIR/logs + if [ -e $_DIR/logs/$PNAME.out.1 ]; then mv $_DIR/logs/$PNAME.out.1 $_DIR/logs/$PNAME.out.2; fi + if [ -e $_DIR/logs/$PNAME.err.1 ]; then mv $_DIR/logs/$PNAME.err.1 $_DIR/logs/$PNAME.err.2; fi + if [ -e $_DIR/logs/$PNAME.out ]; then mv $_DIR/logs/$PNAME.out $_DIR/logs/$PNAME.out.1; fi + if [ -e $_DIR/logs/$PNAME.err ]; then mv $_DIR/logs/$PNAME.err $_DIR/logs/$PNAME.err.1; fi + + nohup $JAVA_HOME/bin/java $JVMARGS -cp $_DIR/config:$_DIR/lib:$_DIR/lib/\*:$CP "$@" $CLASS >> $_DIR/logs/$PNAME.out 2>> $_DIR/logs/$PNAME.err & + + _PID=$! + echo $_PID > $_PIDFILE + sleep 5 + check_status + echo $_STATUS + if [ "$_RUNNING" = "1" ]; then + exit 0 + else + echo "Failed to start - make sure the $SNAME is fully configured properly" + exit 1 + fi + ;; + stop) + if [ "$_RUNNING" = "0" ]; then + echo $_STATUS + remove_pid_file + exit 0 + fi + echo "Stopping $SNAME..." + _PID_TO_KILL=$_PID; + echo "$SNAME (pid=${_PID_TO_KILL}) is stopping..." + kill -TERM $_PID_TO_KILL + sleep 5 + check_status_of_pid $_PID_TO_KILL + if [ "$_RUNNING" = "1" ]; then + kill -TERM $_PID_TO_KILL + fi + while [ "$_RUNNING" = "1" ]; do + sleep 2 + check_status_of_pid $_PID_TO_KILL + done + remove_pid_file + echo "$SNAME has stopped." + exit 0 + ;; + *) + echo "$0 start|stop" + ;; +esac + + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/bin/dcae-controller.sh b/dcae-controller-core/dcae-controller-platform-server/src/main/server/bin/dcae-controller.sh new file mode 100644 index 0000000..51a6416 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/bin/dcae-controller.sh @@ -0,0 +1,130 @@ +#!/bin/bash + +cd $(dirname $(dirname $(readlink -e $0))) + +ROOT=$(pwd) +CMD=$ROOT/bin/controller-platform-server-controller + +mkdir -p logs/ +echo $(date) bin/dcae-controller.sh "$@" >> logs/dcae-controller.sh.log + +if [ -e /opt/app/dcae-controller-platform-server ]; then + ### IST/ETE/PROD deployment + ### verify/fix JAVA and GROOVY setup + FOO=todo +fi + +CMD1=$1 +shift + +case $CMD1 in + start|stop|restart|console) + if [ -e makefile ]; then + make $CMD1 + exit + fi + case $CMD1 in + start) + JVMARGS=$(cat config/controller.properties | grep JVMARGS | sed 's/[^=]*=//') + $CMD $CMD1 $JVMARGS + ;; + stop|console) + $CMD $CMD1 + ;; + *) + $CMD stop + JVMARGS=$(cat config/controller.properties | grep JVMARGS | sed 's/[^=]*=//') + $CMD start $JVMARGS + ;; + esac + exit + ;; + backup|restore) + exit + ;; + config) + /opt/app/dcae-controller-core-utils/bin/setup_https.sh config/controller.properties + exit + ;; + sync-install) + ENV=$1 + DIR=$2 + if [ ! -e config/server.private ]; then + echo "No private key: $(pwd)/config/server.private" + exit 1 + fi + for f in $DIR/config/*; do + echo "Updating config/$(basename $f)" + rm -rf config/$(basename $f) + cp -rp $f config/$(basename $f) + done + for jar in /opt/app/dcae-*-{jars,model,manager,adaptor}/lib/*.jar /opt/app/ncomp-*-{jars,model,manager,adaptor}/lib/*.jar; do + echo "Updating $jar" + cp $jar lib/ + done + exit + ;; + add-service-artifact) + G=$1 + A=$2 + V=$3 + F=$HOME/.m2/repository/$(echo $G | sed 'sx\.x/xg')/$A/$V/$A-$V.jar + #echo Local artifact $F + #if [ ! -e $F ]; then + #mvn org.apache.maven.plugins:maven-dependency-plugin:2.9:copy -Dartifact=$G:$A:$V:jar -DoutputDirectory=/tmp + #F=/tmp/$A-$V.jar + #fi + if [ ! -e $F ]; then F=/home/ubuntu/$A-$V.jar; fi + if [ ! -e $F ]; then echo "unable to find service artifact"; exit 1; fi + if [ -e lib/$A-*.jar ]; then + #echo removing old version + rm -f lib/$A-*.jar + fi + cp $F lib/ + touch config/runtime.properties + sed -i /factory.$A/d config/runtime.properties + jar tf $F | grep Factory.java | grep -v /gui/ | sed 's/.java$//' | sed sx/x.xg | awk -vA=$A '{ print "factory." A "." NR "=" $1}' >> config/runtime.properties + echo bin/dcae-controller.sh add-service-artifact "$@" >> config/init.sh + sort -u config/init.sh > config/init.sh.tmp + mv config/init.sh.tmp config/init.sh + exit + ;; + add-manager) + C2=$1 + U=$2 + P=$(echo $3 | sed 's/%/ /g') + MFILE=config/managers.properties + sed -i /$C2/d $MFILE + echo $C2.endpoint=http://IP:PORT >> $MFILE + echo $C2.user=$U >> $MFILE + echo $C2.password=$P >> $MFILE + exit + ;; + "") + echo " start" + for f in scripts/*groovy; do + cmd=$(basename $f | sed 's/.groovy$//') + echo " $cmd" + done + exit + ;; + usage) + echo ================ start ============================= + echo dcae-controller.sh start + for f in scripts/*groovy; do + cmd=$(basename $f | sed 's/.groovy$//') + echo ================ $cmd ============================= + bin/controller-platform-server-controller groovy scripts/$cmd + done + exit + ;; +esac + +if [ ! -e scripts/$CMD1.groovy ]; then + echo $0 $CMD1 does not exists. + exit 1 +fi + +bin/controller-platform-server-controller groovy scripts/$CMD1.groovy "$@" + + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/console.properties b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/console.properties new file mode 100644 index 0000000..4b63607 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/console.properties @@ -0,0 +1,3 @@ +localhost.endpoint=http://localhost:PORT +localhost.user=console +localhost.password=CONSOLE_PW diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/controller.properties b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/controller.properties new file mode 100644 index 0000000..21ff0a6 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/controller.properties @@ -0,0 +1,8 @@ +server.dir = data/resources +metrics.dir = data/metrics +properties.dir = data/properties +server.port = PORT +server.user.console = CONSOLE_PW +server.user.gui = GUI_PW +server.user.client = CLIENT_PW +server.user.monitor = MONITOR_PW diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/gui.properties b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/gui.properties new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/gui.properties diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/log4j.properties b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/log4j.properties new file mode 100644 index 0000000..529c40e --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/log4j.properties @@ -0,0 +1,91 @@ +#log4j.debug=0 +log4j.rootLogger=warn, file +log4j.logger.org.openecomp.ncomp=info, file +log4j.additivity.org.openecomp.ncomp=false +log4j.logger.org.openecomp.ncomp.datarouter=warn, file +log4j.additivity.org.openecomp.ncomp.datarouter=false +#log4j.logger.org.apache.http.headers=debug, file +#log4j.logger.org.apache.http.wire=debug, file + +## uploaded logger +log4j.logger.org.openecomp.ncomp.sirius.manager.uploaded=info, uploaded +log4j.additivity.org.openecomp.ncomp.sirius.manager.uploaded=false +## request logging +log4j.logger.org.openecomp.ncomp.sirius.manager.ManagementServer.requests=info, requests +log4j.additivity.org.openecomp.ncomp.sirius.manager.ManagementServer.requests=false +## openstack polling +log4j.logger.org.openecomp.ncomp.openstack.OpenStackUtil.polling=info, polling +log4j.additivity.org.openecomp.ncomp.openstack.OpenStackUtil.polling=false + +log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.File=logs/dcae-controller.log +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d %5p [%t] %m %C:%L%n +log4j.appender.file.MaxFileSize=50MB +log4j.appender.file.MaxBackupIndex=5 + +log4j.appender.uploaded=org.apache.log4j.RollingFileAppender +log4j.appender.uploaded.File=logs/dcae-controller-uploaded.log +log4j.appender.uploaded.layout=org.apache.log4j.PatternLayout +log4j.appender.uploaded.layout.ConversionPattern=%d %5p [%t] %m %C:%L%n +log4j.appender.uploaded.MaxFileSize=50MB +log4j.appender.uploaded.MaxBackupIndex=5 + +log4j.appender.requests=org.apache.log4j.RollingFileAppender +log4j.appender.requests.File=logs/dcae-controller-requests.log +log4j.appender.requests.layout=org.apache.log4j.PatternLayout +log4j.appender.requests.layout.ConversionPattern=%d %5p [%t] %m %C:%L%n +log4j.appender.requests.MaxFileSize=50MB +log4j.appender.requests.MaxBackupIndex=5 + +log4j.appender.polling=org.apache.log4j.RollingFileAppender +log4j.appender.polling.File=logs/dcae-controller-polling.log +log4j.appender.polling.layout=org.apache.log4j.PatternLayout +log4j.appender.polling.layout.ConversionPattern=%d %5p [%t] %m %C:%L%n +log4j.appender.polling.MaxFileSize=50MB +log4j.appender.polling.MaxBackupIndex=5 + + +### ECOMP Logging + +log4j.logger.com.att.eelf.audit=info, audit +log4j.additivity.com.att.eelf.audit=false +log4j.logger.com.att.eelf.audit=info, metrics +log4j.additivity.com.att.eelf.metrics=false +log4j.logger.com.att.eelf.audit=info, error +log4j.additivity.com.att.eelf.error=false +log4j.logger.com.att.eelf.audit=info, debug +log4j.additivity.com.att.eelf.debug=false + +log4j.appender.audit=org.apache.log4j.RollingFileAppender +log4j.appender.audit.File=logs/audit.log +log4j.appender.audit.layout=org.apache.log4j.PatternLayout +log4j.appender.audit.layout.ConversionPattern=%d{MM/dd-HH:mm:ss.SSS}|%logger|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{Timer}|%m%n + +log4j.appender.audit.MaxFileSize=50MB +log4j.appender.audit.MaxBackupIndex=5 + +log4j.appender.metrics=org.apache.log4j.RollingFileAppender +log4j.appender.metrics.File=logs/audit.log +log4j.appender.metrics.layout=org.apache.log4j.PatternLayout +log4j.appender.metrics.layout.ConversionPattern=%d{MM/dd-HH:mm:ss.SSS}|%logger|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{Timer}|%m%n + +log4j.appender.metrics.MaxFileSize=50MB +log4j.appender.metrics.MaxBackupIndex=5 + +log4j.appender.error=org.apache.log4j.RollingFileAppender +log4j.appender.error.File=logs/audit.log +log4j.appender.error.layout=org.apache.log4j.PatternLayout +log4j.appender.error.layout.ConversionPattern=%d{MM/dd-HH:mm:ss.SSS}|%logger|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{Timer}|%m%n + +log4j.appender.error.MaxFileSize=50MB +log4j.appender.error.MaxBackupIndex=5 + +log4j.appender.debug=org.apache.log4j.RollingFileAppender +log4j.appender.debug.File=logs/audit.log +log4j.appender.debug.layout=org.apache.log4j.PatternLayout +log4j.appender.debug.layout.ConversionPattern=%d{MM/dd-HH:mm:ss.SSS}|%logger|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{Timer}|%m%n + +log4j.appender.debug.MaxFileSize=50MB +log4j.appender.debug.MaxBackupIndex=5 + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/makefile b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/makefile new file mode 100644 index 0000000..a43b607 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/makefile @@ -0,0 +1,9 @@ + +restart: stop start + +start: + M2_HOME=/home/ncomp/.m2 bin/controller-platform-server-controller start +stop: + bin/controller-platform-server-controller stop +console: + bin/controller-platform-server-controller console diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/pw.sh.sh b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/pw.sh.sh new file mode 100644 index 0000000..af4ae0d --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/config/pw.sh.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +### used to generate random passwords + + +echo '#!/bin/bash' +echo "" + +echo 'cat \' + +for i in CONSOLE GUI CLIENT MONITOR +do + echo ' |' sed s/${i}_PW/$(echo $i:$(date +%s) | sha256sum | base64 | head -c 20 ; echo)/ \\ +done +
\ No newline at end of file diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-dcae-location.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-dcae-location.groovy new file mode 100644 index 0000000..9aff1e2 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-dcae-location.groovy @@ -0,0 +1,50 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh add-dcae-location OPTIONS') +cli.n(longOpt:'name', args:1, 'Name of DCAE location') +cli.l(longOpt:'location', args:1, 'Name of Openstack location') +cli.p(longOpt:'project', args:1, 'Name of Openstack Project') + +def options = cli.parse(args) + +if (options == null || ! options.name || ! options.location || ! options.project ) { + println "Bad Usage:" + cli.usage() + System.exit(1) +} + +server.create("/locations/$options.name", [ openstackProject : [ '$ref' : "/openstack/locations/$options.location/projects/$options.project" ] ]) +// needed to persist. +server.update("/",[:]) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-openstack-location.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-openstack-location.groovy new file mode 100644 index 0000000..3ab8669 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-openstack-location.groovy @@ -0,0 +1,46 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh add-openstack-location OPTIONS') +cli.n(longOpt:'location', args:1, 'Name of location') +cli.k(longOpt:'keystoneURL', args:1, 'Keystone URL') +cli.b(longOpt:'bypassIp', args:1, 'Bypass Ip') +cli.v(longOpt:'version', args:1, 'Openstack version') + +def options = cli.parse(args) + +if (options == null || ! options.location || ! options.keystoneURL || ! options.bypassIp ) { + cli.usage() + System.exit(0) +} + +server.create("/openstack/locations/$options.location", [keystoneUrl:options.keystoneURL, bypassIp:options.bypassIp, version : options.version]) diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-openstack-project.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-openstack-project.groovy new file mode 100644 index 0000000..ab5ab07 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-openstack-project.groovy @@ -0,0 +1,48 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh add-openstack-project OPTIONS') +cli.o(longOpt:'location', args:1, 'Name of Openstack location') +cli.n(longOpt:'project', args:1, 'Name of project') +cli.t(longOpt:'tenantId', args:1, 'Tenant Id') +cli.u(longOpt:'user', args:1, 'User Id for this Tenant') + +def options = cli.parse(args) + +if (options == null || ! options.project || ! options.tenantId || ! options.user || ! options.location ) { + cli.usage() + System.exit(0) +} + +server.create("/openstack/locations/$options.location/projects/$options.project", [tenantId:options.tenantId, adminUser:options.user]) +server.update("/openstack/locations/$options.location/projects/$options.project", [:]) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-service-instance.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-service-instance.groovy new file mode 100644 index 0000000..19808ac --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-service-instance.groovy @@ -0,0 +1,91 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh add-service-instance OPTIONS') +cli.i(longOpt:'instance', args:1, 'Name of Service Instance') +cli.s(longOpt:'service', args:1, 'Name of Service (optional but then descriptor)') +cli.c(longOpt:'config', args:1, 'JSON configuration (optional)') +cli.f(longOpt:'configFile', args:1, 'JSON configuration File (optional)') +cli.C(longOpt:'className', args:1, 'Service Class (optional)') +cli.d(longOpt:'descriptor', args:1, 'Descriptor (optional)') +cli._(longOpt:'debug', args:0, 'Debug') +cli._(longOpt:'controllerEndpoint', args:1, 'Name of controller endpoint (optional)') + +def options = cli.parse(args) + +if (options == null || ! options.instance || ( ! options.service && ! options.descriptor ) ) { + cli.usage() + System.exit(1) +} + +server = new DcaeDcaePlatformControllerConsole("console.properties",options.controllerEndpoint ? options.controllerEndpoint : "localhost") +def service = options.descriptor ? options.descriptor : options.service + + +if (options.config && options.configFile) { + println "only one of --config and --configFile can be specified." + System.exit(1) +} + +def o = [:] + +if (options.config) { + o = Utils.json2object(new JSONObject(options.config)) +} + +if (options.configFile) { + File f = new File(options.configFile) + if (!f.exists()) { + println "Configuration File does not exists: $f.absolutePath" + System.exit(1) + } + o = Utils.json2object(new JSONObject(f.text)) +} + + +if (options.className) o['$class'] = options.className + +if (options.descriptor) { + def d = server.list("/descriptors/$options.descriptor",100) + o['$class'] = "${d.servicePackage}.${d.serviceInstanceClass}" + if (d.vmType != null) o.vmType = [ '$ref' : "/openstack/vmTypes/$d.vmType" ] + if (d.managerPortNumber != null) o.managerPortNumber = d.managerPortNumber +} + +if (options.debug) { + println o +} + +server.create("/services/$service/instances/$options.instance", o) +// needed to persist. +server.update("/",[:]) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-service.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-service.groovy new file mode 100644 index 0000000..e2c8c36 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/add-service.groovy @@ -0,0 +1,71 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh add-service OPTIONS') +cli.s(longOpt:'service', args:1, 'Name of Service') +cli.c(longOpt:'config', args:1, 'JSON configuration (optional)') +cli.f(longOpt:'configFile', args:1, 'JSON configuration File (optional)') +cli.C(longOpt:'className', args:1, 'Service Class') + +def options = cli.parse(args) + +if (options == null || ! options.service || ! options.className ) { + cli.usage() + System.exit(1) +} + +if (options.config && options.configFile) { + println "only one of --config and --configFile can be specified." + System.exit(1) +} + +def o = [:] + +if (options.config) { + o = Utils.json2object(new JSONObject(options.config)) +} + +if (options.configFile) { + File f = new File(options.configFile) + if (!f.exists()) { + println "Configuration File does not exists: $f.absolutePath" + System.exit(1) + } + o = Utils.json2object(new JSONObject(f.text)) +} + + +o['$class'] = options.className + +server.create("/services/$options.service", o) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/configure-service-instance.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/configure-service-instance.groovy new file mode 100644 index 0000000..29e9935 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/configure-service-instance.groovy @@ -0,0 +1,50 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh configure-service-instance OPTIONS') +cli.s(longOpt:'service', args:1, 'Name of Service') +cli.i(longOpt:'instance', args:1, 'Name of Service Instance') +cli._(longOpt:'controllerEndpoint', args:1, 'Name of controller endpoint (optional)') + +def options = cli.parse(args) + +if (options == null || ! options.service || ! options.instance ) { + cli.usage() + System.exit(1) +} +server = new DcaeDcaePlatformControllerConsole("console.properties",options.controllerEndpoint ? options.controllerEndpoint : "localhost") + +def o = [ + instanceName : options.instance, +] + +server.operation("/services/$options.service", "pushManagerConfiguration", o) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/console.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/console.groovy new file mode 100644 index 0000000..fa62023 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/console.groovy @@ -0,0 +1,27 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/create-keypair.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/create-keypair.groovy new file mode 100644 index 0000000..d7cc2ee --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/create-keypair.groovy @@ -0,0 +1,51 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +import org.openecomp.ncomp.utils.CryptoUtils +import java.text.SimpleDateFormat + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh operation-service-instance OPTIONS') +cli.f(longOpt:'fileroot', args:1, 'File name Root') + +def options = cli.parse(args) + +if (options == null || ! options.fileroot ) { + cli.usage() + System.exit(1) +} + +["private","public"].each { x -> + def f = new File("${options.fileroot}.$x") + if (! f.exists() ) return + println "$f already exists. Proceed? [no, yes]" + def r = System.in.newReader().readLine() + switch (r) { + case "yes": break + default: System.exit(0) + } + def t = new SimpleDateFormat("yyyy-MM-dd-HH-mm").format(f.lastModified()) + f.renameTo "${options.fileroot}.$x.$t" +} + +CryptoUtils.createKeyPair(options.fileroot); + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/create-object.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/create-object.groovy new file mode 100644 index 0000000..43f9664 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/create-object.groovy @@ -0,0 +1,57 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh create-object OPTIONS') +cli.p(longOpt:'path', args:1, argName:'path', 'Resource Path') +cli.f(longOpt:'file', args:1, argName:'configFile', 'JSON configuration File (optional)') +cli.C(longOpt:'className', args:1, argName:'className', 'Class Name') + +def options = cli.parse(args) + +if (options == null || ! options.path || ! options.file ) { + cli.usage() + System.exit(1) +} + +File f = new File(options.file) +if (!f.exists()) { + println "Configuration File does not exists: $f.absolutePath" + System.exit(1) +} +o = Utils.json2object(new JSONObject(f.text)) + + +if ( options.className ) o['$class'] = options.className + +server.create(options.path, o) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/databus-refresh.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/databus-refresh.groovy new file mode 100644 index 0000000..b0791ba --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/databus-refresh.groovy @@ -0,0 +1,47 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh databus-refresh OPTIONS') +cli.m(longOpt:'nameMatch', args:1, 'Name Match') + +def options = cli.parse(args) + +if (options == null || ! options.nameMatch) { + cli.usage() + System.exit(1) +} + +def o = [nameMatch:options.nameMatch] + +server.operation("/", "refreshDataBus", o) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/decrypt-value.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/decrypt-value.groovy new file mode 100644 index 0000000..de75151 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/decrypt-value.groovy @@ -0,0 +1,38 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +import org.openecomp.ncomp.utils.CryptoUtils + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh encrypt-password OPTIONS') +cli.v(longOpt:'value', args:1, 'Value to decrypt') + +def options = cli.parse(args) + +if (options == null || ! options.value ) { + cli.usage() + System.exit(1) +} + +str = CryptoUtils.decryptPrivate(CryptoUtils.getKey("config/server.private"),options.value); + +println "$str" diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/delete-object.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/delete-object.groovy new file mode 100644 index 0000000..1a6278e --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/delete-object.groovy @@ -0,0 +1,45 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh delete-object OPTIONS') +cli.p(longOpt:'path', args:1, argName:'path', 'Resource Path') + +def options = cli.parse(args) + +if (options == null || ! options.path ) { + cli.usage() + System.exit(1) +} + +server.delete(options.path) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-descriptor.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-descriptor.groovy new file mode 100644 index 0000000..9487c79 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-descriptor.groovy @@ -0,0 +1,82 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh deploy-descriptor OPTIONS') +cli.n(longOpt:'name', args:1, 'Descriptor Name') +cli._(longOpt:'debug', args:0, 'Debug') + +def options = cli.parse(args) + +if (options == null || ! options.name ) { + cli.usage() + System.exit(1) +} + +def d = server.list("/descriptors/$options.name",100) + +if (options.debug) { + println Utils.p(d) +} + +/* +if (d.artifact != null) { +Utils.runCmd("bin/dcae-controller.sh add-service-artifact org.openecomp.dcae.controller $d.artifact-model 0.1.0-SNAPSHOT",5000) + +switch (d.artifact) { +case "dcae-controller-service-cdap": + Utils.runCmd("bin/dcae-controller.sh add-service-artifact org.openecomp.dcae.controller $d.artifact-adaptor 0.1.0-SNAPSHOT", 5000) ; break +default: + Utils.runCmd("bin/dcae-controller.sh add-service-artifact org.openecomp.dcae.controller $d.artifact-manager 0.1.0-SNAPSHOT", 5000) +} + +switch (d['$class']) { + case "org.openecomp.dcae.controller.service.vm.VirtualMachineServiceDescriptor": + if (d.encryptedPassword == null || ! d.encryptedPassword.startsWith("rsa:") ) { + System.err.println "Bad Password: $d.encryptedPassword" + System.exit(2) + } + def p = d.encryptedPassword.replace(" ","%") + Utils.runCmd("bin/dcae-controller.sh add-manager ${d.servicePackage}.${d.serviceInstanceClass} $d.managerUser $p",5000) +} + + +Utils.runCmd("bin/dcae-controller.sh stop", 20000) +Utils.runCmd("bin/dcae-controller.sh start", 30000) + +Utils.runCmd("sleep 25",60000) +} +*/ + +def o = [:] +o['$class'] = "${d.servicePackage}.${d.serviceClass}" +if (d.managerPortNumber != null) o.managerPortNumber = d.managerPortNumber + +// creating service +server.create("/services/$options.name", o) diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-manual-vm-service-instance.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-manual-vm-service-instance.groovy new file mode 100644 index 0000000..f25dbea --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-manual-vm-service-instance.groovy @@ -0,0 +1,58 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh deploy-service-instance OPTIONS') +cli.i(longOpt:'instance', args:1, 'Name of Service Instance') +cli.s(longOpt:'service', args:1, 'Name of Service') +cli._(longOpt:'publicIp', args:1, 'Public IP') +cli._(longOpt:'privateIp', args:1, 'Private IP') +cli._(longOpt:'port', args:1, 'Port Number') + +def options = cli.parse(args) + +if (options == null || ! options.service || ! options.instance ) { + cli.usage() + System.exit(1) +} + +def o = [ + '$class':"org.openecomp.dcae.controller.service.vm.PhysicalMachine", +] + +if (options.publicIp) o.publicIp = options.publicIp +if (options.privateIp) o.privateIp = options.privateIp +if (options.port) o.managerPortNumber = options.port + +def n ="manual:$options.service:$options.instance:0" + +server.create("/services/$options.service/instances/$options.instance/servers/$n", o) diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-service-instance.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-service-instance.groovy new file mode 100644 index 0000000..61c45c5 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-service-instance.groovy @@ -0,0 +1,51 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh deploy-service-instance OPTIONS') +cli.i(longOpt:'instance', args:1, argName:'instance', 'Name of Service Instance') +cli.s(longOpt:'service', args:1, argName:'service', 'Name of Service') +cli.c(longOpt:'container', args:1, argName:'container', 'Path to Service Container') +cli._(longOpt:'controllerEndpoint', args:1, 'Name of controller endpoint (optional)') + +def options = cli.parse(args) + +if (options == null || ! options.service || ! options.instance ) { + cli.usage() + System.exit(1) +} + +server = new DcaeDcaePlatformControllerConsole("console.properties",options.controllerEndpoint ? options.controllerEndpoint : "localhost") + +def o = [ instanceName: options.instance ] + +if (options.container) o.containerPath = options.container +server.operation("/services/$options.service", "deploy", o) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-undeployed-descriptors.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-undeployed-descriptors.groovy new file mode 100644 index 0000000..1b9c7cb --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-undeployed-descriptors.groovy @@ -0,0 +1,59 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh deploy-undeployed-descriptors OPTIONS') + +def options = cli.parse(args) + +if (options == null ) { + println "Bad Usage:" + cli.usage() + System.exit(1) +} + +l1 = server.list("/descriptors").descriptors +l2 = server.list("/services").services + +println "descriptors: $l1" +println "services: $l2" + +(l1 - l2).each { n -> + d = server.list("/descriptors/$n") + switch (d['$class']) { + case null: break + default: + println "Deploying undeployed descriptor $n" + Utils.runCmd("bin/dcae-controller.sh deploy-descriptor --name $n", 100000) + l3 = server.list("/",0).services + if (l3.contains(n)) + println "Done: services: ${server.list("/services").services}" + else + System.err.println "Failed to deploy $n: services: ${server.list("/services").services}" + } +} + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-user.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-user.groovy new file mode 100644 index 0000000..5100faa --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-user.groovy @@ -0,0 +1,50 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh deploy-user OPTIONS') +cli.p(longOpt:'project', args:1, 'Openstack Project') +cli.l(longOpt:'location', args:1, 'Openstack Location') +cli.u(longOpt:'user', args:1, 'User') + +def options = cli.parse(args) + +if (options == null || ! options.user || ! options.location || ! options.project ) { + cli.usage() + System.exit(1) +} + +server.operation("/openstack/locations/$options.location", "deployUser", [ + projectName : options.project, + user : [ '$ref' : "/users/$options.user", '$refroot' :"/" ] +]) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-vmType.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-vmType.groovy new file mode 100644 index 0000000..40669d8 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/deploy-vmType.groovy @@ -0,0 +1,47 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh deploy-vmType OPTIONS') +cli.v(longOpt:'vmType', args:1, 'Name of VmType') +cli.l(longOpt:'location', args:1, 'Openstack Location') +cli.p(longOpt:'project', args:1, 'Openstack Project') + +def options = cli.parse(args) + +if (options == null || ! options.vmType || ! options.location || ! options.project ) { + cli.usage() + System.exit(1) +} + +server.operation("/openstack/locations/$options.location", "deployVmType", [ projectName : options.project, vmTypeName : options.vmType ]) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/encrypt-file.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/encrypt-file.groovy new file mode 100644 index 0000000..ee146c1 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/encrypt-file.groovy @@ -0,0 +1,64 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +import org.openecomp.ncomp.utils.CryptoUtils +import java.security.SecureRandom; +import java.math.BigInteger; +import org.json.JSONObject; +import org.yaml.snakeyaml.DumperOptions; +import org.yaml.snakeyaml.Yaml; +import static org.openecomp.ncomp.sirius.manager.console.Utils.*; + +class X { +static def object2yaml(Object object) { + DumperOptions options = new DumperOptions(); + options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); + options.setSplitLines(true); + options.setWidth(100000); + Yaml y = new Yaml(options); + JSONObject json = (JSONObject) object2json(object); + def data = y.load(json.toString()); + return y.dump(data); +} +} + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh encrypt-file OPTIONS') +cli.k(longOpt:'key', args:1, 'Public Key File') +cli.f(longOpt:'file', args:1, 'File') + +def options = cli.parse(args) + +if (options == null || ! options.key || ! options.file ) { + cli.usage() + System.exit(1) +} + +def password = new BigInteger(130, new SecureRandom()).toString(32); + +println password + +str = CryptoUtils.encrypt(password,new File(options.file).text).replace("\r",""); + +str1 = CryptoUtils.encryptPublic(CryptoUtils.getKey(options.key),password).replace("\r",""); + +println X.object2yaml(['encrypted-file': [ content:str, 'encrypted-password' : str1 ]]) diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/encrypt-password.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/encrypt-password.groovy new file mode 100644 index 0000000..d13ce8c --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/encrypt-password.groovy @@ -0,0 +1,43 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +import org.openecomp.ncomp.utils.CryptoUtils + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh encrypt-password OPTIONS') +cli.k(longOpt:'key', args:1, 'Public Key File') + +def options = cli.parse(args) + +if (options == null || ! options.key ) { + cli.usage() + System.exit(1) +} + +def password = System.console().readLine 'Password to encrypt?' + + +str = CryptoUtils.encryptPublic(CryptoUtils.getKey(options.key),password); + +str = str.replace('\n',' ').replace('\r',' ') + +println "rsa:$str" diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/get-service-instance-configuration.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/get-service-instance-configuration.groovy new file mode 100644 index 0000000..bf1b44e --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/get-service-instance-configuration.groovy @@ -0,0 +1,46 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh get-service-instance-configuration OPTIONS') +cli.i(longOpt:'instance', args:1, 'Name of Service Instance') +cli.s(longOpt:'service', args:1, 'Name of Service') + +def options = cli.parse(args) + +if (options == null || ! options.instance || ! options.service ) { + cli.usage() + System.exit(1) +} + +println Utils.object2json(server.list("/services/$options.service/instances/$options.instance", 100)).toString(2) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/get-service-instance-manager-configuration.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/get-service-instance-manager-configuration.groovy new file mode 100644 index 0000000..cf18a8d --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/get-service-instance-manager-configuration.groovy @@ -0,0 +1,48 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh get-service-instance-configuration OPTIONS') +cli.i(longOpt:'instance', args:1, 'Name of Service Instance') +cli.s(longOpt:'service', args:1, 'Name of Service') +cli._(longOpt:'controllerEndpoint', args:1, 'Name of controller endpoint (optional)') + +def options = cli.parse(args) + +if (options == null || ! options.instance || ! options.service ) { + cli.usage() + System.exit(1) +} + +server = new DcaeDcaePlatformControllerConsole("console.properties",options.controllerEndpoint ? options.controllerEndpoint : "localhost") +def o = [ instanceName : options.instance ] +println Utils.object2json(server.operation("/services/$options.service", "managerConfiguration", o)).toString(2) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/init-controller.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/init-controller.groovy new file mode 100644 index 0000000..28d0a78 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/init-controller.groovy @@ -0,0 +1,32 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + +try { server.delete("/openstack") } catch (e) {} +server.create("/openstack", [:]) diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/list-object.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/list-object.groovy new file mode 100644 index 0000000..9c1b03a --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/list-object.groovy @@ -0,0 +1,48 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh list-object OPTIONS') +cli.p(longOpt:'path', args:1, argName:'path', 'Resource Path') +cli.l(longOpt:'levels', args:1, argName:'levels', 'Resource Path') + +def options = cli.parse(args) + +if (options == null || ! options.path ) { + cli.usage() + System.exit(1) +} + +def levels = options.levels ? Integer.parseInt(options.levels) : 0 + +println Utils.p(server.list(options.path,levels)) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/operation-service-instance.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/operation-service-instance.groovy new file mode 100644 index 0000000..b71031b --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/operation-service-instance.groovy @@ -0,0 +1,66 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh operation-service-instance OPTIONS') +cli.s(longOpt:'service', args:1, 'Name of Service') +cli.i(longOpt:'instance', args:1, 'Name of Service Instance') +cli.o(longOpt:'operation', args:1, 'Name of Operation') +cli.p(longOpt:'parameters', args:1, 'JSON Object with parameters (optional)') + +def options = cli.parse(args) + +if (options == null || ! options.service || ! options.operation || ! options.instance ) { + cli.usage() + System.exit(1) +} + +def o = [ + instanceName : options.instance, + operation : options.operation, +] + +if (options.parameters) { + o.parameters = "$options.parameters" +} + +def res = server.operation("/services/$options.service", "managerOperation", o) + +try { + def json = new JSONObject(res.returns) + println json.toString(2) +} +catch (e) { + println res.returns +} + + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/operation-service.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/operation-service.groovy new file mode 100644 index 0000000..7a0e5c0 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/operation-service.groovy @@ -0,0 +1,53 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh operation-service OPTIONS') +cli.s(longOpt:'service', args:1, 'Name of Service') +cli.o(longOpt:'operation', args:1, 'Name of Operation') +cli.p(longOpt:'parameters', args:1, 'JSON Object with parameters (optional)') + +def options = cli.parse(args) + +if (options == null || ! options.service || ! options.operation ) { + cli.usage() + System.exit(1) +} + +def o = [:] + +if (options.parameters) { + o = Utils.json2object(new JSONObject(options.parameters)) +} + +println Utils.object2json(server.operation("/services/$options.service", options.operation, o)).toString(2) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/rackspace-substitute.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/rackspace-substitute.groovy new file mode 100644 index 0000000..855e151 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/rackspace-substitute.groovy @@ -0,0 +1,60 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +import org.yaml.snakeyaml.Yaml; + +import org.openecomp.ncomp.utils.CryptoUtils; +import org.openecomp.ncomp.utils.StringUtil; + +import groovy.text.SimpleTemplateEngine +import groovy.io.FileType + +import org.openecomp.ncomp.webservice.utils.FileUtils +import static org.openecomp.ncomp.sirius.manager.console.Utils.*; + + +def cli = new CliBuilder(usage:'dcae-controller.sh rackspace-substitute OPTIONS') +cli.a(longOpt:'from', args:1, 'Source Directory') +cli.b(longOpt:'to', args:1, 'Destination Directory') +cli.f(longOpt:'file', args:1, 'Substitution YAML File') + +def options = cli.parse(args) + +def fromDir = new File(options.from) +def toDir = new File(options.to) + +if (toDir.exists()) + FileUtils.deleteDirectory(toDir) + +def f = new File(options.file) +Yaml yaml = new Yaml(); +def m = yaml.load(f.text) + +if (m['POLICY-IP'] == null) m['POLICY-IP'] = "10.0.6.1" + +fromDir.eachFileRecurse (FileType.FILES) { file -> + def ofile = new File(file.toString().replace(options.from, options.to)) + switch (file.name) { + default: + ofile.parentFile.mkdirs() + ofile.text = StringUtil.expandUsingJson(file.text, object2json(m), "@") + } +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/report.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/report.groovy new file mode 100644 index 0000000..a40e367 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/report.groovy @@ -0,0 +1,64 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh reports OPTIONS') +cli.n(longOpt:'name', args:1, 'Report Name') +cli._(longOpt:'debug', args:0, 'Debug') +cli._(longOpt:'controllerEndpoint', args:1, 'Name of controller endpoint (optional)') + +def options = cli.parse(args) +server = new DcaeDcaePlatformControllerConsole("console.properties",options.controllerEndpoint ? options.controllerEndpoint : "localhost") + +if (options == null || ! options.name ) { + cli.usage() + System.exit(1) +} + +def table = server.operation("/gui","getTable", [path:"$options.name",start:"-24hour",end:"now"]) + + +def convert(table) { +// println table.rows.get(0) + def res = [header:[],rows:[]] + table.columns.each { col -> + res.header += col.colName + } + table.rows.each { row -> + def r = [] + row.cells.each { cell -> + r += cell.value + } + res.rows += [ r ] + } + return res +} + +println Utils.pTable(convert(table.returns),"txt",System.out) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/setup-openstack-bash-shell.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/setup-openstack-bash-shell.groovy new file mode 100644 index 0000000..5dd25f8 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/setup-openstack-bash-shell.groovy @@ -0,0 +1,74 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.openecomp.ncomp.sirius.manager.JavaHttpClient; + + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh setup-openstack-bash-shell OPTIONS') +cli.l(longOpt:'location', args:1, 'Openstack Location') +cli.p(longOpt:'project', args:1, 'Openstack Project') + +def options = cli.parse(args) + +if (options == null || ! options.location || ! options.project ) { + cli.usage() + System.exit(1) +} + +def x = server.list("/openstack/locations/$options.location", 1000) +def p = x.projects[options.project] + +if (p == null) { + println "no project $options.project exists at location $options.location" + System.exit(1) +} + +def prop = org.openecomp.ncomp.utils.PropertyUtil.getPropertiesFromClasspath("openstack.properties") + +def pw = prop.getProperty("${options.location}.password.$p.adminUser") +if (pw == null) { + println "Unable to find property ${options.location}.password.$p.adminUser in openstack.properties" + System.exit(1) +} + +def f = new File(".openstack.${options.location}.${options.project}") +if (f.exists()) f.delete() + +f << "export OS_AUTH_URL=$x.keystoneUrl\n" +f << "export OS_TENANT_ID=$p.tenantId\n" +f << "export OS_TENANT_NAME=$options.location\n" +f << "export OS_PROJECT_NAME=$options.location\n" +f << "export OS_USERNAME=$p.adminUser\n" +f << "export OS_PASSWORD=${JavaHttpClient.decryptPassword(pw)}\n" +if (p.region != null) f << "export OS_REGION_NAME=$p.region\n" + +println "Wrote . $f" + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/sync-configuration-from-directory.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/sync-configuration-from-directory.groovy new file mode 100644 index 0000000..a155b9c --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/sync-configuration-from-directory.groovy @@ -0,0 +1,83 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject +import org.openecomp.ncomp.sirius.manager.ManagementServer; + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh deploy-descriptor OPTIONS') +cli.d(longOpt:'directory', args:1, 'Configuration Directory') +cli._(longOpt:'force', args:0, 'Force update') +cli._(longOpt:'debug', args:0, 'Debug') + +def options = cli.parse(args) + +if (options == null || ! options.directory ) { + cli.usage() + System.exit(1) +} + +m = new ManagementServer() +m.eFactory = org.openecomp.dcae.controller.platform.controller.ControllerFactory.eINSTANCE +m.eClassName = "DcaePlatformController" +org.openecomp.dcae.controller.platform.controller.ControllerPackage.eINSTANCE +org.openecomp.dcae.controller.service.vm.VmPackage.eINSTANCE +m.addFactory(org.openecomp.dcae.controller.service.vm.VmFactory.eINSTANCE) +m.addRuntimeFactories(null) + +def o = m.load(options.directory) +o = Utils.json2object(Utils.object2json(o)) +o.services = null + +if (o.openstack != null && o.openstack.locations != null) { + o.openstack.locations.each { locN, loc -> + loc.projects.each { projectN, project -> + project.each { n2, v2 -> + switch (n2) { + case "privateNetwork" : + case "region" : + case "publicNetwork" : + case "adminUser" : + case "apiKey" : + case "tenantId" : break + default: project[n2] = null + } + } + } + } +} + +if (options.force) { o['$forcedUpdate'] = 1 } +if (options.debug) { println Utils.object2json(o).toString(2) } + + +// currently references are not handled correctly in SOMF to new objects. So doing it twice fixes that. +// first time we do not need to persist the changes on the controller +o['$nosave'] = 1 +server.update("/",o) +o['$nosave'] = null +server.update("/",o) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/sync-configuration.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/sync-configuration.groovy new file mode 100644 index 0000000..386515a --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/sync-configuration.groovy @@ -0,0 +1,59 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject +import org.openecomp.ncomp.sirius.manager.ManagementServer; + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh sync-configuration OPTIONS') +cli.e(longOpt:'environment', args:1, 'Configuration Directory') +cli._(longOpt:'force', args:0, 'Force update') +cli._(longOpt:'debug', args:0, 'Debug') + +def options = cli.parse(args) + +if (options == null || ! options.environment ) { + cli.usage() + System.exit(1) +} + +def dir = "GITLINK/$options.environment/controller-gen" + +def f = new File(dir) + +if (!f.exists()) { + println "Configuration directory does not exists: $dir" + System.exit(1) +} + +Utils.runCmd("bin/dcae-controller.sh sync-install $options.environment $dir", 60000) + +Utils.runCmd("bin/dcae-controller.sh start", 60000) + +Utils.runCmd("bin/dcae-controller.sh sync-configuration-from-directory --directory $dir/resources", 600000) + +Utils.runCmd("bin/dcae-controller.sh deploy-undeployed-descriptors", 6000000) + +Utils.runCmd("bin/dcae-controller.sh sync-services-from-directory --directory $dir/services-resources", 600000) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/sync-services-from-directory.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/sync-services-from-directory.groovy new file mode 100644 index 0000000..845b510 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/sync-services-from-directory.groovy @@ -0,0 +1,90 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject +import org.openecomp.ncomp.sirius.manager.ManagementServer; +import org.openecomp.ncomp.webservice.utils.JsonUtils + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh sync-services-from-directory OPTIONS') +cli.d(longOpt:'directory', args:1, 'Configuration Directory') +cli._(longOpt:'force', args:0, 'Force update') +cli._(longOpt:'debug', args:0, 'Debug') + +def options = cli.parse(args) + +if (options == null || ! options.directory ) { + cli.usage() + System.exit(1) +} + +m = new ManagementServer() +m.eFactory = org.openecomp.dcae.controller.platform.controller.ControllerFactory.eINSTANCE +m.eClassName = "DcaePlatformController" +org.openecomp.dcae.controller.platform.controller.ControllerPackage.eINSTANCE +org.openecomp.dcae.controller.service.vm.VmPackage.eINSTANCE +m.addFactory(org.openecomp.dcae.controller.service.vm.VmFactory.eINSTANCE) +m.addRuntimeFactories(null) + +def o = m.load(options.directory) +o = Utils.json2object(Utils.object2json(o)) + +def rootFile = new File("$options.directory/services") + +if (options.debug) { println Utils.object2json(o).toString(2) } + +def services = server.list("/services").services + +rootFile.listFiles().each { File f -> +// println "$f" + String sname = f.name + if (sname.endsWith(".json")) return + println "service $sname" + if (! services.contains(sname)) { + println "No such service: $sname" + return + } + def instances = server.list("/services/$sname/instances").instances + def dir = new File("$options.directory/services/$sname/instances") + dir.listFiles().each { File f1 -> + def iname = f1.name.replace(".json", "") + JSONObject instance = JsonUtils.file2json("$options.directory/services/$sname/instances/${iname}.json") +// println "json ${instance.toString(2)}" + instance.put('$nosave',1); +// instance.put('$useNull',1); + if (instances.contains(iname)) { + server.update("/services/$sname/instances/$iname",instance) + println "updating instance $iname" + } else { + server.create("/services/$sname/instances/$iname",instance) + println "creating instance $iname" + } + } +} + +server.update("/",[:]) + + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/tosca-add-blueprint.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/tosca-add-blueprint.groovy new file mode 100644 index 0000000..b08fdc3 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/tosca-add-blueprint.groovy @@ -0,0 +1,69 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh add-service-instance OPTIONS') +cli.i(longOpt:'instance', args:1, 'Name of Service Instance') +cli.s(longOpt:'service', args:1, 'Name of Service (optional but then descriptor)') +cli.f(longOpt:'toscaFile', args:1, 'Tosca configuration File') +cli._(longOpt:'debug', args:0, 'Debug') +cli._(longOpt:'controllerEndpoint', args:1, 'Name of controller endpoint (optional)') + +def options = cli.parse(args) + +if (options == null || ! options.instance || ! options.service || ! options.toscaFile ) { + cli.usage() + System.exit(1) +} + +server = new DcaeDcaePlatformControllerConsole("console.properties",options.controllerEndpoint ? options.controllerEndpoint : "localhost") + +def service = options.descriptor ? options.descriptor : options.service + +if (options.config) { + o = Utils.json2object(new JSONObject(options.config)) +} + +File f = new File(options.toscaFile) +if (!f.exists()) { + println "Tosca File does not exists: $f.absolutePath" + System.exit(1) +} + +def o = [instanceName:options.instance,blueprintYaml:f.text] + + +if (options.debug) { + println o +} + +server.operation("/services/$options.service", "uploadBlueprint", o) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-service-instance-chef.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-service-instance-chef.groovy new file mode 100644 index 0000000..1e7ed99 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-service-instance-chef.groovy @@ -0,0 +1,68 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +
+
+import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole
+import org.openecomp.ncomp.sirius.manager.console.Utils
+
+import org.json.JSONObject
+import org.junit.After;
+
+server = new DcaeDcaePlatformControllerConsole("console.properties","localhost")
+
+def p(x) { Utils.object2json(x).toString(2) }
+
+// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html
+def cli = new CliBuilder(usage:'dcae-controller.sh undeploy-service-instance OPTIONS')
+cli.i(longOpt:'instance', args:1, argName:'instance', 'Name of Service Instance')
+cli.s(longOpt:'service', args:1, argName:'service', 'Name of Service')
+
+def options = cli.parse(args)
+
+if (options == null || ! options.service || ! options.instance ) {
+ cli.usage()
+ System.exit(1)
+}
+
+def servers = []
+
+server.listAll("/services/$options.service/instances/$options.instance/servers/.*/networks/.*").each { p ->
+
+ def x = server.list(p)
+ if ( x.dnsName == null) return
+ servers += x.dnsName
+}
+
+servers.each { n ->
+ try {
+ println "$n"
+ Utils.runCmd("knife node delete $n --yes",10000)
+ Utils.runCmd("knife client delete $n --yes",10000)
+ }
+ catch (e) {
+ println "Error removing node from CHEF"
+ }
+}
+
+server.operation("/services/$options.service", "undeploy", [ instanceName: options.instance ])
+
+
diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-service-instance.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-service-instance.groovy new file mode 100644 index 0000000..bc5de44 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-service-instance.groovy @@ -0,0 +1,46 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh undeploy-service-instance OPTIONS') +cli.i(longOpt:'instance', args:1, argName:'instance', 'Name of Service Instance') +cli.s(longOpt:'service', args:1, argName:'service', 'Name of Service') + +def options = cli.parse(args) + +if (options == null || ! options.service || ! options.instance ) { + cli.usage() + System.exit(1) +} + +server.operation("/services/$options.service", "undeploy", [ instanceName: options.instance ]) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-user.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-user.groovy new file mode 100644 index 0000000..daac7f2 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-user.groovy @@ -0,0 +1,50 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh undeploy-user OPTIONS') +cli.p(longOpt:'project', args:1, 'Openstack Project') +cli.l(longOpt:'location', args:1, 'Openstack Location') +cli.u(longOpt:'user', args:1, 'User') + +def options = cli.parse(args) + +if (options == null || ! options.user || ! options.location || ! options.project ) { + cli.usage() + System.exit(1) +} + +server.operation("/openstack/locations/$options.location", "undeployUser", [ + projectName : options.project, + user : [ '$ref' : "/users/$options.user", '$refroot' :"/" ] +]) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-vmType.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-vmType.groovy new file mode 100644 index 0000000..68c82d7 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/undeploy-vmType.groovy @@ -0,0 +1,47 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh undeploy-vmType OPTIONS') +cli.v(longOpt:'vmType', args:1, 'Name of VmType') +cli.l(longOpt:'location', args:1, 'Openstack Location') +cli.p(longOpt:'project', args:1, 'Openstack Project') + +def options = cli.parse(args) + +if (options == null || ! options.vmType || ! options.location || ! options.project ) { + cli.usage() + System.exit(1) +} + +server.operation("/openstack/locations/$options.location", "undeployVmType", [ projectName : options.project, vmTypeName : options.vmType ]) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/update-configuration-from-policy-service-instance.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/update-configuration-from-policy-service-instance.groovy new file mode 100644 index 0000000..09ef819 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/update-configuration-from-policy-service-instance.groovy @@ -0,0 +1,50 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh update-configuration-from-policy-service-instance OPTIONS') +cli.s(longOpt:'service', args:1, 'Name of Service') +cli.i(longOpt:'instance', args:1, 'Name of Service Instance') + +def options = cli.parse(args) + +if (options == null || ! options.service || ! options.instance ) { + cli.usage() + System.exit(1) +} + +def o = [ + instanceName : options.instance, +] + +server.operation("/services/$options.service", "updateConfigurationFromPolicy", o) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/update-object.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/update-object.groovy new file mode 100644 index 0000000..df45f25 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/update-object.groovy @@ -0,0 +1,67 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils +import org.json.JSONObject + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } + + +// http://docs.groovy-lang.org/latest/html/gapi/groovy/util/CliBuilder.html +def cli = new CliBuilder(usage:'dcae-controller.sh create-object OPTIONS') +cli.p(longOpt:'path', args:1, argName:'path', 'Resource Path') +cli.f(longOpt:'file', args:1, argName:'configFile', 'JSON configuration File (optional)') +cli.c(longOpt:'config', args:1, argName:'config', 'JSON configuration (optional)') + +def options = cli.parse(args) + +if (options == null || ! options.path || ( ! options.file && ! options.config ) ) { + cli.usage() + System.exit(1) +} + +if (options.config && options.file) { + println "only one of --config and --configFile can be specified." + System.exit(1) +} + +def o = [:] + +if (options.config) { + o = Utils.json2object(new JSONObject(options.config)) +} + +if (options.file) { + File f = new File(options.file) + if (!f.exists()) { + println "Configuration File does not exists: $f.absolutePath" + System.exit(1) + } + o = Utils.json2object(new JSONObject(f.text)) +} + +server.update(options.path, o) + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/wait-for.groovy b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/wait-for.groovy new file mode 100644 index 0000000..1c2f840 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/server/scripts/wait-for.groovy @@ -0,0 +1,101 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +import org.yaml.snakeyaml.Yaml; + + +import groovy.text.SimpleTemplateEngine +import groovy.io.FileType +import static org.openecomp.ncomp.sirius.manager.console.Utils.*; + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerConsole + +server = new DcaeDcaePlatformControllerConsole("console.properties","localhost") + +def cli = new CliBuilder(usage:'dcae-controller.sh wait-for OPTIONS') +cli.p(longOpt:'path', args:1, 'Resource Path') +cli.e(longOpt:'exists', args:0, 'Object Exists') +cli.a(longOpt:'attribute', args:1, 'Attribute') +cli.m(longOpt:'match', args:1, 'Match') +cli.n(longOpt:'isNull', args:0, 'Is Null') +cli.N(longOpt:'isNotNull', args:0, 'Is not Null') +cli.f(longOpt:'frequency', args:1, 'Polling Frequency (seconds)') +cli.t(longOpt:'timeout', args:1, 'Timeout (seconds)') +cli._(longOpt:'debug', args:0, 'Debug') +cli.v(longOpt:'verbose', args:0, 'Verbose') + +def options = cli.parse(args) + +if (args.length == 0 ) { + cli.usage() + System.exit(1) +} + + +def timeout = options.timeout ? Long.parseLong(options.timeout) * 1000 : 300000 // default 5 min +def frequency = options.frequency ? Long.parseLong(options.frequency) * 1000 : 30000 // default 30 seconds +def path = options.path ? options.path : "/" // default 30 seconds + +Date start = new Date() + +def status = "UNKNOWN" +while (new Date().time < start.time + timeout) { + def o = null + try { o = server.list(path,0) } catch (e) { + if (options.debug) println "LISTING error: $e" + } + if (options.debug) { + if (o) + println "object is ${object2json(o).toString(2)}" + else + println "object is NULL" + } + if ( ! options.exists && o == null) { + println "Error: caller expect the object to exists but it does not: $path" + System.exit(2) + } + if (options.exists && o == null) { + // need to keep waiting + status = "Object does not exists: $path" + } + else { + if ( ! options.attribute ) System.exit(0) + def a = options.attribute + def v = o[a] + if (options.isNull) { + if (v == null) System.exit(0) else status = "Attribute not null: $path@$a" + } + if (options.isNotNull) { + if (v != null) System.exit(0) else status = "Attribute null: $path@$a" + } + if (options.match) { + if ("$v" == options.match) System.exit(0) else status = "Attribute match: $path@$a '$v' != '$options.match'" + } + } + if (options.verbose) + println "Waiting: $status : waited ${new Date().time-start.time} milliseconds" + Thread.sleep(frequency) +} + +println "Error: Timeout: $status : waited ${new Date().time-start.time} milliseconds" +System.exit(2) + + diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/ControllerCluster.yaml b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/ControllerCluster.yaml new file mode 100644 index 0000000..a3d8f3d --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/ControllerCluster.yaml @@ -0,0 +1,25 @@ +operations: + pushData: {} + receiveData: {} + REMOTE_pushData: + decription: Remote call pushData + REMOTE_receiveData: + decription: Remote call receiveData +messages: + dummy: {} + pushData: + errorCode: pushData-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + receiveData: + errorCode: receiveData-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + REMOTE_pushData: + errorCode: REMOTE-pushData-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_receiveData: + errorCode: REMOTE-receiveData-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/ControllerVirtualMachineService.yaml b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/ControllerVirtualMachineService.yaml new file mode 100644 index 0000000..6ac8c34 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/ControllerVirtualMachineService.yaml @@ -0,0 +1,135 @@ +operations: + deploy: {} + undeploy: {} + test: {} + suspend: {} + resume: {} + pushManagerConfiguration: {} + pollManagerConfiguration: {} + managerConfiguration: {} + managerOperation: {} + updateConfigurationFromPolicy: {} + runHealthTests: {} + updateDeploymentStatus: {} + REMOTE_deploy: + decription: Remote call deploy + REMOTE_undeploy: + decription: Remote call undeploy + REMOTE_test: + decription: Remote call test + REMOTE_suspend: + decription: Remote call suspend + REMOTE_resume: + decription: Remote call resume + REMOTE_pushManagerConfiguration: + decription: Remote call pushManagerConfiguration + REMOTE_pollManagerConfiguration: + decription: Remote call pollManagerConfiguration + REMOTE_managerConfiguration: + decription: Remote call managerConfiguration + REMOTE_managerOperation: + decription: Remote call managerOperation + REMOTE_updateConfigurationFromPolicy: + decription: Remote call updateConfigurationFromPolicy + REMOTE_runHealthTests: + decription: Remote call runHealthTests + REMOTE_updateDeploymentStatus: + decription: Remote call updateDeploymentStatus +messages: + dummy: {} + deploy: + errorCode: deploy-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + undeploy: + errorCode: undeploy-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + test: + errorCode: test-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + suspend: + errorCode: suspend-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + resume: + errorCode: resume-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + pushManagerConfiguration: + errorCode: pushManagerConfiguration-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + pollManagerConfiguration: + errorCode: pollManagerConfiguration-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + managerConfiguration: + errorCode: managerConfiguration-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + managerOperation: + errorCode: managerOperation-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + updateConfigurationFromPolicy: + errorCode: updateConfigurationFromPolicy-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + runHealthTests: + errorCode: runHealthTests-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + updateDeploymentStatus: + errorCode: updateDeploymentStatus-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + REMOTE_deploy: + errorCode: REMOTE-deploy-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_undeploy: + errorCode: REMOTE-undeploy-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_test: + errorCode: REMOTE-test-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_suspend: + errorCode: REMOTE-suspend-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_resume: + errorCode: REMOTE-resume-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_pushManagerConfiguration: + errorCode: REMOTE-pushManagerConfiguration-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_pollManagerConfiguration: + errorCode: REMOTE-pollManagerConfiguration-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_managerConfiguration: + errorCode: REMOTE-managerConfiguration-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_managerOperation: + errorCode: REMOTE-managerOperation-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_updateConfigurationFromPolicy: + errorCode: REMOTE-updateConfigurationFromPolicy-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_runHealthTests: + errorCode: REMOTE-runHealthTests-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_updateDeploymentStatus: + errorCode: REMOTE-updateDeploymentStatus-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/DcaePlatformController.yaml b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/DcaePlatformController.yaml new file mode 100644 index 0000000..08497ed --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/DcaePlatformController.yaml @@ -0,0 +1,135 @@ +operations: + logs: {} + metrics: {} + properties: {} + uploadInfo: {} + getValues: {} + getValuesAll: {} + getMessages: {} + getRequestLogger: {} + evaluate: {} + update: {} + deployDescriptor: {} + refreshDataBus: {} + REMOTE_logs: + decription: Remote call logs + REMOTE_metrics: + decription: Remote call metrics + REMOTE_properties: + decription: Remote call properties + REMOTE_uploadInfo: + decription: Remote call uploadInfo + REMOTE_getValues: + decription: Remote call getValues + REMOTE_getValuesAll: + decription: Remote call getValuesAll + REMOTE_getMessages: + decription: Remote call getMessages + REMOTE_getRequestLogger: + decription: Remote call getRequestLogger + REMOTE_evaluate: + decription: Remote call evaluate + REMOTE_update: + decription: Remote call update + REMOTE_deployDescriptor: + decription: Remote call deployDescriptor + REMOTE_refreshDataBus: + decription: Remote call refreshDataBus +messages: + dummy: {} + logs: + errorCode: logs-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + metrics: + errorCode: metrics-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + properties: + errorCode: properties-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + uploadInfo: + errorCode: uploadInfo-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + getValues: + errorCode: getValues-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + getValuesAll: + errorCode: getValuesAll-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + getMessages: + errorCode: getMessages-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + getRequestLogger: + errorCode: getRequestLogger-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + evaluate: + errorCode: evaluate-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + update: + errorCode: update-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + deployDescriptor: + errorCode: deployDescriptor-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + refreshDataBus: + errorCode: refreshDataBus-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + REMOTE_logs: + errorCode: REMOTE-logs-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_metrics: + errorCode: REMOTE-metrics-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_properties: + errorCode: REMOTE-properties-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_uploadInfo: + errorCode: REMOTE-uploadInfo-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_getValues: + errorCode: REMOTE-getValues-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_getValuesAll: + errorCode: REMOTE-getValuesAll-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_getMessages: + errorCode: REMOTE-getMessages-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_getRequestLogger: + errorCode: REMOTE-getRequestLogger-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_evaluate: + errorCode: REMOTE-evaluate-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_update: + errorCode: REMOTE-update-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_deployDescriptor: + errorCode: REMOTE-deployDescriptor-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_refreshDataBus: + errorCode: REMOTE-refreshDataBus-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/GuiClientApi.yaml b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/GuiClientApi.yaml new file mode 100644 index 0000000..bf3d69d --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/GuiClientApi.yaml @@ -0,0 +1,69 @@ +operations: + getTree: {} + getObject: {} + getTimeSerie: {} + getTable: {} + getHtml: {} + getGraph: {} + REMOTE_getTree: + decription: Remote call getTree + REMOTE_getObject: + decription: Remote call getObject + REMOTE_getTimeSerie: + decription: Remote call getTimeSerie + REMOTE_getTable: + decription: Remote call getTable + REMOTE_getHtml: + decription: Remote call getHtml + REMOTE_getGraph: + decription: Remote call getGraph +messages: + dummy: {} + getTree: + errorCode: getTree-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + getObject: + errorCode: getObject-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + getTimeSerie: + errorCode: getTimeSerie-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + getTable: + errorCode: getTable-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + getHtml: + errorCode: getHtml-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + getGraph: + errorCode: getGraph-FAILED-5001W + messageFormat: '{0}' + description: Operation Failed with Exception + REMOTE_getTree: + errorCode: REMOTE-getTree-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_getObject: + errorCode: REMOTE-getObject-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_getTimeSerie: + errorCode: REMOTE-getTimeSerie-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_getTable: + errorCode: REMOTE-getTable-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_getHtml: + errorCode: REMOTE-getHtml-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception + REMOTE_getGraph: + errorCode: REMOTE-getGraph-FAILED-5001W + messageFormat: '{0}' + description: Remote Operation Failed with Exception 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 new file mode 100644 index 0000000..05b41bf --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerCluster.java @@ -0,0 +1,145 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * 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.openecomp.ncomp.sirius.manager.ISiriusPlugin; +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.logger.EcompLogger; + +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 ISiriusPlugin { + public static final Logger logger = Logger.getLogger(DcaeControllerCluster.class); + static final EcompLogger ecomplogger = EcompLogger.getEcompLogger(); + 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.recordMetricEventStart(); + ecomplogger.setOperation(ControllerClusterOperationEnum.pushData); + ecomplogger.setInstanceId(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.pushData, e.toString()); + throw e; + } + 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.recordMetricEventStart(); + ecomplogger.setOperation(ControllerClusterOperationEnum.receiveData); + ecomplogger.setInstanceId(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.receiveData, e.toString()); + throw e; + } + 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 getSomfProvider() { + return controller; + } +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerClusterClient.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerClusterClient.java new file mode 100644 index 0000000..a274556 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerClusterClient.java @@ -0,0 +1,107 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * 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 org.openecomp.ncomp.sirius.manager.AbstractClient; +import org.openecomp.ncomp.sirius.manager.HighAvailabilityClient; +import org.openecomp.ncomp.sirius.manager.GenericHttpClient; + +import org.apache.log4j.Logger; + +import org.openecomp.logger.EcompLogger; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; + +import org.openecomp.dcae.controller.platform.controller.impl.ControllerClusterImpl; +import org.openecomp.dcae.controller.platform.controller.ControllerPackage; +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.servers.controller.DcaeDcaePlatformController; + + + + +@SuppressWarnings("unchecked") +public class DcaeControllerClusterClient extends ControllerClusterImpl { + public static final Logger logger = Logger.getLogger(DcaeControllerClusterClient.class); + static final EcompLogger ecomplogger = EcompLogger.getEcompLogger(); + public AbstractClient client; + + public DcaeControllerClusterClient(String file, String name) { + DcaeDcaePlatformController.ecoreSetup(); + client = new GenericHttpClient(file,name); + client.add("/cluster", this); + } + + public DcaeControllerClusterClient(String file, String name1, String name2) { + HighAvailabilityClient client1 = new HighAvailabilityClient(file,name1,name2); + client = client1.all; // requests should be forwarded to all. + client.add("/cluster", this); + } + + public DcaeControllerClusterClient(AbstractClient c) { + client = c; + client.add("/resources", this); + } + + + + + public void pushData(String path, java.lang.String serverName, java.lang.String dataName) { + EClass c = ControllerPackage.eINSTANCE.getControllerCluster(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(ControllerClusterOperationEnum.REMOTE_pushData); + + try { + client.operationPath(path, c, "pushData", null, serverName,dataName); + } + catch (Exception e) { + ecomplogger.warn(ControllerClusterMessageEnum.REMOTE_pushData, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@pushData: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + + public void receiveData(String path, java.lang.String serverName, java.lang.String dataName, java.util.Date time, java.lang.String content) { + EClass c = ControllerPackage.eINSTANCE.getControllerCluster(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(ControllerClusterOperationEnum.REMOTE_receiveData); + + try { + client.operationPath(path, c, "receiveData", null, serverName,dataName,time,content); + } + catch (Exception e) { + ecomplogger.warn(ControllerClusterMessageEnum.REMOTE_receiveData, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@receiveData: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerClusterConsole.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerClusterConsole.java new file mode 100644 index 0000000..00c0b5f --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerClusterConsole.java @@ -0,0 +1,79 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +// Autogenerated +// Do not edit but extend this class as needed +package org.openecomp.dcae.controller.platform.servers.controller; + + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; + +import org.openecomp.ncomp.sirius.manager.console.Console; +import org.openecomp.ncomp.sirius.manager.AbstractClient; +import org.openecomp.ncomp.sirius.manager.ManagementServerError; + + + + +public class DcaeControllerClusterConsole extends Console { + public static final Logger logger = Logger.getLogger(DcaeControllerClusterConsole.class); + protected DcaeControllerClusterClient controller; + + + + + public DcaeControllerClusterConsole(String filename, String name) { + super(filename, name); + controller = new DcaeControllerClusterClient(filename,name); + client = controller.client; + + } + + public DcaeControllerClusterConsole(AbstractClient c) { + controller = new DcaeControllerClusterClient(c); + client = controller.client; + } + + + public void pushData(String path, java.lang.String serverName, java.lang.String dataName) { + + try { + controller.pushData(path,serverName,dataName); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void receiveData(String path, java.lang.String serverName, java.lang.String dataName, java.util.Date time, java.lang.String content) { + + try { + controller.receiveData(path,serverName,dataName,time,content); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerClusterProviderTemplate.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerClusterProviderTemplate.java new file mode 100644 index 0000000..6726313 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerClusterProviderTemplate.java @@ -0,0 +1,77 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + +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.ISiriusPlugin; +import org.openecomp.ncomp.sirius.manager.ISiriusServer; +import org.openecomp.ncomp.sirius.function.FunctionUtils; + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; +import org.json.JSONObject; + + + +import org.openecomp.ncomp.sirius.manager.BasicAdaptorProvider; + + +import org.openecomp.dcae.controller.platform.controller.impl.ControllerClusterImpl; +import org.openecomp.dcae.controller.platform.controller.ControllerCluster; + + +public class DcaeControllerClusterProviderTemplate extends BasicAdaptorProvider { + private static final Logger logger = Logger.getLogger(DcaeControllerClusterProviderTemplate.class); + ControllerCluster o; + + public DcaeControllerClusterProviderTemplate(ISiriusServer controller, ControllerCluster o) { + super(controller, o); + this.o = o; + } + + public void pushData(java.lang.String serverName, java.lang.String dataName) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void receiveData(java.lang.String serverName, java.lang.String dataName, java.util.Date time, java.lang.String content) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + + + + + + + +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerFactory.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerFactory.java new file mode 100644 index 0000000..a4d1bc0 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerFactory.java @@ -0,0 +1,66 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * 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 org.eclipse.emf.ecore.EPackage; +import org.apache.log4j.Logger; + +import org.openecomp.ncomp.sirius.manager.ISiriusServer; + +import org.openecomp.dcae.controller.platform.controller.DcaePlatformController; +import org.openecomp.dcae.controller.platform.controller.ControllerPackage; +import org.openecomp.dcae.controller.platform.controller.impl.ControllerFactoryImpl; + + + + +import org.openecomp.dcae.controller.platform.controller.ControllerCluster; +import org.openecomp.dcae.controller.platform.controller.ControllerVirtualMachineService; + +public class DcaeControllerFactory extends ControllerFactoryImpl { + public static final Logger logger = Logger.getLogger(DcaeControllerFactory.class); + ISiriusServer server = null; + @Override + public EPackage getEPackage() { return ControllerPackage.eINSTANCE; } + public DcaeControllerFactory(ISiriusServer server) { + this.server = server; + } + @Override + public DcaePlatformController createDcaePlatformController() { + return new DcaeDcaePlatformController(server); + } + + + @Override + public ControllerCluster createControllerCluster() { + return new DcaeControllerCluster(server); + } + + @Override + public ControllerVirtualMachineService createControllerVirtualMachineService() { + return new DcaeControllerVirtualMachineService(server); + } + + +} 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 new file mode 100644 index 0000000..f83bac3 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerVirtualMachineService.java @@ -0,0 +1,415 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * 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.openecomp.ncomp.sirius.manager.ISiriusPlugin; +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.logger.EcompLogger; + +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 ISiriusPlugin { + public static final Logger logger = Logger.getLogger(DcaeControllerVirtualMachineService.class); + static final EcompLogger ecomplogger = EcompLogger.getEcompLogger(); + 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.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.deploy); + ecomplogger.setInstanceId(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.deploy, e.toString()); + throw e; + } + 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.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.undeploy); + ecomplogger.setInstanceId(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.undeploy, e.toString()); + throw e; + } + 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.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.test); + ecomplogger.setInstanceId(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.test, e.toString()); + throw e; + } + 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.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.suspend); + ecomplogger.setInstanceId(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.suspend, e.toString()); + throw e; + } + 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.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.resume); + ecomplogger.setInstanceId(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.resume, e.toString()); + throw e; + } + 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.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.pushManagerConfiguration); + ecomplogger.setInstanceId(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.pushManagerConfiguration, e.toString()); + throw e; + } + 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.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.pollManagerConfiguration); + ecomplogger.setInstanceId(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.pollManagerConfiguration, e.toString()); + throw e; + } + 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.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.managerConfiguration); + ecomplogger.setInstanceId(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.managerConfiguration, e.toString()); + throw e; + } + 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.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.managerOperation); + ecomplogger.setInstanceId(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.managerOperation, e.toString()); + throw e; + } + 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.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.updateConfigurationFromPolicy); + ecomplogger.setInstanceId(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.updateConfigurationFromPolicy, e.toString()); + throw e; + } + 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.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.runHealthTests); + ecomplogger.setInstanceId(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.runHealthTests, e.toString()); + throw e; + } + 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.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.updateDeploymentStatus); + ecomplogger.setInstanceId(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.updateDeploymentStatus, e.toString()); + throw e; + } + 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 getSomfProvider() { + return controller; + } +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerVirtualMachineServiceClient.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerVirtualMachineServiceClient.java new file mode 100644 index 0000000..09d2371 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerVirtualMachineServiceClient.java @@ -0,0 +1,277 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * 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 org.openecomp.ncomp.sirius.manager.AbstractClient; +import org.openecomp.ncomp.sirius.manager.HighAvailabilityClient; +import org.openecomp.ncomp.sirius.manager.GenericHttpClient; + +import org.apache.log4j.Logger; + +import org.openecomp.logger.EcompLogger; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; + +import org.openecomp.dcae.controller.platform.controller.impl.ControllerVirtualMachineServiceImpl; +import org.openecomp.dcae.controller.platform.controller.ControllerPackage; +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.servers.controller.DcaeDcaePlatformController; + + + + +@SuppressWarnings("unchecked") +public class DcaeControllerVirtualMachineServiceClient extends ControllerVirtualMachineServiceImpl { + public static final Logger logger = Logger.getLogger(DcaeControllerVirtualMachineServiceClient.class); + static final EcompLogger ecomplogger = EcompLogger.getEcompLogger(); + public AbstractClient client; + + public DcaeControllerVirtualMachineServiceClient(String file, String name) { + DcaeDcaePlatformController.ecoreSetup(); + client = new GenericHttpClient(file,name); + client.add("/cont", this); + } + + public DcaeControllerVirtualMachineServiceClient(String file, String name1, String name2) { + HighAvailabilityClient client1 = new HighAvailabilityClient(file,name1,name2); + client = client1.all; // requests should be forwarded to all. + client.add("/cont", this); + } + + public DcaeControllerVirtualMachineServiceClient(AbstractClient c) { + client = c; + client.add("/resources", this); + } + + + + + public void deploy(String path, java.lang.String instanceName, java.lang.String containerPath) { + EClass c = ControllerPackage.eINSTANCE.getControllerVirtualMachineService(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.REMOTE_deploy); + + try { + client.operationPath(path, c, "deploy", null, instanceName,containerPath); + } + catch (Exception e) { + ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REMOTE_deploy, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@deploy: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + + public void undeploy(String path, java.lang.String instanceName) { + EClass c = ControllerPackage.eINSTANCE.getControllerVirtualMachineService(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.REMOTE_undeploy); + + try { + client.operationPath(path, c, "undeploy", null, instanceName); + } + catch (Exception e) { + ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REMOTE_undeploy, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@undeploy: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + + public org.openecomp.dcae.controller.core.service.HealthTestResponse test(String path, java.lang.String instanceName) { + EClass c = ControllerPackage.eINSTANCE.getControllerVirtualMachineService(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.REMOTE_test); + org.openecomp.dcae.controller.core.service.HealthTestResponse res; + try { + res = (org.openecomp.dcae.controller.core.service.HealthTestResponse) client.operationPath(path, c, "test", null, instanceName); + } + catch (Exception e) { + ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REMOTE_test, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@test: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + + + public void suspend(String path, java.lang.String instanceName) { + EClass c = ControllerPackage.eINSTANCE.getControllerVirtualMachineService(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.REMOTE_suspend); + + try { + client.operationPath(path, c, "suspend", null, instanceName); + } + catch (Exception e) { + ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REMOTE_suspend, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@suspend: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + + public void resume(String path, java.lang.String instanceName) { + EClass c = ControllerPackage.eINSTANCE.getControllerVirtualMachineService(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.REMOTE_resume); + + try { + client.operationPath(path, c, "resume", null, instanceName); + } + catch (Exception e) { + ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REMOTE_resume, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@resume: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + + public void pushManagerConfiguration(String path, java.lang.String instanceName) { + EClass c = ControllerPackage.eINSTANCE.getControllerVirtualMachineService(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.REMOTE_pushManagerConfiguration); + + try { + client.operationPath(path, c, "pushManagerConfiguration", null, instanceName); + } + catch (Exception e) { + ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REMOTE_pushManagerConfiguration, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@pushManagerConfiguration: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + + public void pollManagerConfiguration(String path, java.lang.String instanceName) { + EClass c = ControllerPackage.eINSTANCE.getControllerVirtualMachineService(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.REMOTE_pollManagerConfiguration); + + try { + client.operationPath(path, c, "pollManagerConfiguration", null, instanceName); + } + catch (Exception e) { + ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REMOTE_pollManagerConfiguration, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@pollManagerConfiguration: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + + public org.eclipse.emf.ecore.EObject managerConfiguration(String path, java.lang.String instanceName) { + EClass c = ControllerPackage.eINSTANCE.getControllerVirtualMachineService(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.REMOTE_managerConfiguration); + org.eclipse.emf.ecore.EObject res; + try { + res = (org.eclipse.emf.ecore.EObject) client.operationPath(path, c, "managerConfiguration", null, instanceName); + } + catch (Exception e) { + ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REMOTE_managerConfiguration, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@managerConfiguration: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + + + public org.json.JSONObject managerOperation(String path, java.lang.String instanceName, java.lang.String operation, org.json.JSONObject parameters) { + EClass c = ControllerPackage.eINSTANCE.getControllerVirtualMachineService(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.REMOTE_managerOperation); + org.json.JSONObject res; + try { + res = (org.json.JSONObject) client.operationPath(path, c, "managerOperation", null, instanceName,operation,parameters); + } + catch (Exception e) { + ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REMOTE_managerOperation, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@managerOperation: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + + + public void updateConfigurationFromPolicy(String path, java.lang.String instanceName) { + EClass c = ControllerPackage.eINSTANCE.getControllerVirtualMachineService(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.REMOTE_updateConfigurationFromPolicy); + + try { + client.operationPath(path, c, "updateConfigurationFromPolicy", null, instanceName); + } + catch (Exception e) { + ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REMOTE_updateConfigurationFromPolicy, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@updateConfigurationFromPolicy: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + + public void runHealthTests(String path) { + EClass c = ControllerPackage.eINSTANCE.getControllerVirtualMachineService(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.REMOTE_runHealthTests); + + try { + client.operationPath(path, c, "runHealthTests", null); + } + catch (Exception e) { + ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REMOTE_runHealthTests, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@runHealthTests: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + + public void updateDeploymentStatus(String path) { + EClass c = ControllerPackage.eINSTANCE.getControllerVirtualMachineService(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(ControllerVirtualMachineServiceOperationEnum.REMOTE_updateDeploymentStatus); + + try { + client.operationPath(path, c, "updateDeploymentStatus", null); + } + catch (Exception e) { + ecomplogger.warn(ControllerVirtualMachineServiceMessageEnum.REMOTE_updateDeploymentStatus, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@updateDeploymentStatus: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerVirtualMachineServiceConsole.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerVirtualMachineServiceConsole.java new file mode 100644 index 0000000..ada979d --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerVirtualMachineServiceConsole.java @@ -0,0 +1,189 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +// Autogenerated +// Do not edit but extend this class as needed +package org.openecomp.dcae.controller.platform.servers.controller; + + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; + +import org.openecomp.ncomp.sirius.manager.console.Console; +import org.openecomp.ncomp.sirius.manager.AbstractClient; +import org.openecomp.ncomp.sirius.manager.ManagementServerError; + + + + +public class DcaeControllerVirtualMachineServiceConsole extends Console { + public static final Logger logger = Logger.getLogger(DcaeControllerVirtualMachineServiceConsole.class); + protected DcaeControllerVirtualMachineServiceClient controller; + + + + + public DcaeControllerVirtualMachineServiceConsole(String filename, String name) { + super(filename, name); + controller = new DcaeControllerVirtualMachineServiceClient(filename,name); + client = controller.client; + + } + + public DcaeControllerVirtualMachineServiceConsole(AbstractClient c) { + controller = new DcaeControllerVirtualMachineServiceClient(c); + client = controller.client; + } + + + public void deploy(String path, java.lang.String instanceName, java.lang.String containerPath) { + + try { + controller.deploy(path,instanceName,containerPath); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void undeploy(String path, java.lang.String instanceName) { + + try { + controller.undeploy(path,instanceName); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public org.openecomp.dcae.controller.core.service.HealthTestResponse test(String path, java.lang.String instanceName) { + org.openecomp.dcae.controller.core.service.HealthTestResponse res = null; + try { + res = controller.test(path,instanceName); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + return res; + } + + public void suspend(String path, java.lang.String instanceName) { + + try { + controller.suspend(path,instanceName); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void resume(String path, java.lang.String instanceName) { + + try { + controller.resume(path,instanceName); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void pushManagerConfiguration(String path, java.lang.String instanceName) { + + try { + controller.pushManagerConfiguration(path,instanceName); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void pollManagerConfiguration(String path, java.lang.String instanceName) { + + try { + controller.pollManagerConfiguration(path,instanceName); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public org.eclipse.emf.ecore.EObject managerConfiguration(String path, java.lang.String instanceName) { + org.eclipse.emf.ecore.EObject res = null; + try { + res = controller.managerConfiguration(path,instanceName); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + return res; + } + + public org.json.JSONObject managerOperation(String path, java.lang.String instanceName, java.lang.String operation, org.json.JSONObject parameters) { + org.json.JSONObject res = null; + try { + res = controller.managerOperation(path,instanceName,operation,parameters); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + return res; + } + + public void updateConfigurationFromPolicy(String path, java.lang.String instanceName) { + + try { + controller.updateConfigurationFromPolicy(path,instanceName); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void runHealthTests(String path) { + + try { + controller.runHealthTests(path); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void updateDeploymentStatus(String path) { + + try { + controller.updateDeploymentStatus(path); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerVirtualMachineServiceProviderTemplate.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerVirtualMachineServiceProviderTemplate.java new file mode 100644 index 0000000..0847e77 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeControllerVirtualMachineServiceProviderTemplate.java @@ -0,0 +1,137 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + +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.ISiriusPlugin; +import org.openecomp.ncomp.sirius.manager.ISiriusServer; +import org.openecomp.ncomp.sirius.function.FunctionUtils; + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; +import org.json.JSONObject; + + + +import org.openecomp.ncomp.sirius.manager.BasicAdaptorProvider; + + +import org.openecomp.dcae.controller.platform.controller.impl.ControllerVirtualMachineServiceImpl; +import org.openecomp.dcae.controller.platform.controller.ControllerVirtualMachineService; + + +public class DcaeControllerVirtualMachineServiceProviderTemplate extends BasicAdaptorProvider { + private static final Logger logger = Logger.getLogger(DcaeControllerVirtualMachineServiceProviderTemplate.class); + ControllerVirtualMachineService o; + + public DcaeControllerVirtualMachineServiceProviderTemplate(ISiriusServer controller, ControllerVirtualMachineService o) { + super(controller, o); + this.o = o; + } + + public void deploy(java.lang.String instanceName, java.lang.String containerPath) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void undeploy(java.lang.String instanceName) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public org.openecomp.dcae.controller.core.service.HealthTestResponse test(java.lang.String instanceName) { + org.openecomp.dcae.controller.core.service.HealthTestResponse res = null; + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void suspend(java.lang.String instanceName) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void resume(java.lang.String instanceName) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void pushManagerConfiguration(java.lang.String instanceName) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void pollManagerConfiguration(java.lang.String instanceName) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public org.eclipse.emf.ecore.EObject managerConfiguration(java.lang.String instanceName) { + org.eclipse.emf.ecore.EObject res = null; + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public org.json.JSONObject managerOperation(java.lang.String instanceName, java.lang.String operation, org.json.JSONObject parameters) { + org.json.JSONObject res = null; + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void updateConfigurationFromPolicy(java.lang.String instanceName) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void runHealthTests() { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void updateDeploymentStatus() { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + + + + + + + +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeDcaePlatformController.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeDcaePlatformController.java new file mode 100644 index 0000000..402f708 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeDcaePlatformController.java @@ -0,0 +1,448 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * 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.openecomp.ncomp.sirius.manager.ISiriusPlugin; +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.logger.EcompLogger; + +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.DcaePlatformControllerOperationEnum; +import org.openecomp.dcae.controller.platform.servers.controller.logging.DcaePlatformControllerMessageEnum; + + + + + + + +import java.util.Date; + + + + + +import org.openecomp.ncomp.sirius.manager.server.LoggerInfo; + + + + + +import org.openecomp.ncomp.sirius.manager.server.ServerFactory; + + +import org.openecomp.dcae.controller.platform.controller.impl.DcaePlatformControllerImpl; + + + +public class DcaeDcaePlatformController extends DcaePlatformControllerImpl implements IRequestHandler, ISwaggerHandler, ISiriusPlugin { + public static final Logger logger = Logger.getLogger(DcaeDcaePlatformController.class); + static final EcompLogger ecomplogger = EcompLogger.getEcompLogger(); + public DcaeDcaePlatformControllerProvider controller; + ISiriusServer server; + + public DcaeDcaePlatformController(ISiriusServer server) { + this.server = server; + this.controller = new DcaeDcaePlatformControllerProvider(server,this); + } + + public void deployDescriptor(java.lang.String name) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "deployDescriptor", ApiRequestStatus.START, duration_,name); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.deployDescriptor); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.deployDescriptor(name); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "deployDescriptor", ApiRequestStatus.ERROR, duration_,name); + System.err.println("ERROR: " + e); + ecomplogger.warn(DcaePlatformControllerMessageEnum.deployDescriptor, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "deployDescriptor", ApiRequestStatus.OKAY, duration_,name); + + } + + public void refreshDataBus(java.lang.String nameMatch) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "refreshDataBus", ApiRequestStatus.START, duration_,nameMatch); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.refreshDataBus); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.refreshDataBus(nameMatch); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "refreshDataBus", ApiRequestStatus.ERROR, duration_,nameMatch); + System.err.println("ERROR: " + e); + ecomplogger.warn(DcaePlatformControllerMessageEnum.refreshDataBus, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "refreshDataBus", ApiRequestStatus.OKAY, duration_,nameMatch); + + } + + public void logs(org.json.JSONObject cx, EList<org.openecomp.ncomp.core.logs.LogMessage> logs) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "logs", ApiRequestStatus.START, duration_,cx,logs); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.logs); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.logs(cx,logs); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "logs", ApiRequestStatus.ERROR, duration_,cx,logs); + System.err.println("ERROR: " + e); + ecomplogger.warn(DcaePlatformControllerMessageEnum.logs, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "logs", ApiRequestStatus.OKAY, duration_,cx,logs); + + } + + public void metrics(org.json.JSONObject cx, EList<org.openecomp.ncomp.core.metrics.Metric> metrics) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "metrics", ApiRequestStatus.START, duration_,cx,metrics); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.metrics); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.metrics(cx,metrics); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "metrics", ApiRequestStatus.ERROR, duration_,cx,metrics); + System.err.println("ERROR: " + e); + ecomplogger.warn(DcaePlatformControllerMessageEnum.metrics, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "metrics", ApiRequestStatus.OKAY, duration_,cx,metrics); + + } + + public void properties(org.json.JSONObject cx, EList<org.openecomp.ncomp.sirius.manager.properties.AbstractProperty> l) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "properties", ApiRequestStatus.START, duration_,cx,l); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.properties); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.properties(cx,l); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "properties", ApiRequestStatus.ERROR, duration_,cx,l); + System.err.println("ERROR: " + e); + ecomplogger.warn(DcaePlatformControllerMessageEnum.properties, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "properties", ApiRequestStatus.OKAY, duration_,cx,l); + + } + + public void uploadInfo(org.json.JSONObject cx, EList<org.openecomp.ncomp.sirius.manager.server.ManagementInfo> info) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "uploadInfo", ApiRequestStatus.START, duration_,cx,info); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.uploadInfo); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.uploadInfo(cx,info); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "uploadInfo", ApiRequestStatus.ERROR, duration_,cx,info); + System.err.println("ERROR: " + e); + ecomplogger.warn(DcaePlatformControllerMessageEnum.uploadInfo, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "uploadInfo", ApiRequestStatus.OKAY, duration_,cx,info); + + } + + public EList<org.openecomp.ncomp.core.metrics.DoubleMetric> getValues(org.json.JSONObject cx, 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; + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "getValues", ApiRequestStatus.START, duration_,cx,path,start,end,option,relativeInterval); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.getValues); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + res = controller.getValues(cx,path,start,end,option,relativeInterval); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getValues", ApiRequestStatus.ERROR, duration_,cx,path,start,end,option,relativeInterval); + System.err.println("ERROR: " + e); + ecomplogger.warn(DcaePlatformControllerMessageEnum.getValues, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getValues", ApiRequestStatus.OKAY, duration_,cx,path,start,end,option,relativeInterval); + return res; + } + + public EList<org.openecomp.ncomp.core.metrics.DoubleMetric> getValuesAll(org.json.JSONObject cx, 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; + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "getValuesAll", ApiRequestStatus.START, duration_,cx,path,metrics,start,end,option,relativeInterval); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.getValuesAll); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + res = controller.getValuesAll(cx,path,metrics,start,end,option,relativeInterval); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getValuesAll", ApiRequestStatus.ERROR, duration_,cx,path,metrics,start,end,option,relativeInterval); + System.err.println("ERROR: " + e); + ecomplogger.warn(DcaePlatformControllerMessageEnum.getValuesAll, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getValuesAll", ApiRequestStatus.OKAY, duration_,cx,path,metrics,start,end,option,relativeInterval); + return res; + } + + public EList<org.openecomp.ncomp.core.logs.LogMessage> getMessages(org.json.JSONObject cx, java.lang.String path, java.lang.Long start, java.lang.Long end) { + EList<org.openecomp.ncomp.core.logs.LogMessage> res = null; + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "getMessages", ApiRequestStatus.START, duration_,cx,path,start,end); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.getMessages); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + res = controller.getMessages(cx,path,start,end); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getMessages", ApiRequestStatus.ERROR, duration_,cx,path,start,end); + System.err.println("ERROR: " + e); + ecomplogger.warn(DcaePlatformControllerMessageEnum.getMessages, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getMessages", ApiRequestStatus.OKAY, duration_,cx,path,start,end); + 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; + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "getRequestLogger", ApiRequestStatus.START, duration_,userName,action,resourcePath,context); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.getRequestLogger); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + res = controller.getRequestLogger(userName,action,resourcePath,context); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getRequestLogger", ApiRequestStatus.ERROR, duration_,userName,action,resourcePath,context); + System.err.println("ERROR: " + e); + ecomplogger.warn(DcaePlatformControllerMessageEnum.getRequestLogger, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getRequestLogger", ApiRequestStatus.OKAY, duration_,userName,action,resourcePath,context); + 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; + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "evaluate", ApiRequestStatus.START, duration_,path,function); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.evaluate); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + res = controller.evaluate(path,function); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "evaluate", ApiRequestStatus.ERROR, duration_,path,function); + System.err.println("ERROR: " + e); + ecomplogger.warn(DcaePlatformControllerMessageEnum.evaluate, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "evaluate", ApiRequestStatus.OKAY, duration_,path,function); + return res; + } + + public void update(java.lang.String path, org.openecomp.ncomp.core.function.Function function) { + + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "update", ApiRequestStatus.START, duration_,path,function); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.update); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + controller.update(path,function); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "update", ApiRequestStatus.ERROR, duration_,path,function); + System.err.println("ERROR: " + e); + ecomplogger.warn(DcaePlatformControllerMessageEnum.update, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "update", ApiRequestStatus.OKAY, duration_,path,function); + + } + + + + @Override + public Object handleJson(String userName, String action, String resourcePath, JSONObject json, JSONObject context) { + return controller.handleJson(userName,action,resourcePath,json,context); + } + + @Override + public Object handleBinary(String userName, String action, String resourcePath, InputStream in) { + return controller.handleBinary(userName,action,resourcePath,in); + } + + + +@Override +public void updateSwagger(String path, SwaggerUtils swagger) { + controller.updateSwagger(path,swagger); +} + + + + + @Override + public void start() { + controller.start(); + } + + public static void ecoreSetup() { + DcaeDcaePlatformControllerProvider.ecoreSetup(); + } + public DcaeDcaePlatformControllerProvider getSomfProvider() { + return controller; + } +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeDcaePlatformControllerClient.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeDcaePlatformControllerClient.java new file mode 100644 index 0000000..e9409b3 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeDcaePlatformControllerClient.java @@ -0,0 +1,276 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * 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 org.openecomp.ncomp.sirius.manager.AbstractClient; +import org.openecomp.ncomp.sirius.manager.HighAvailabilityClient; +import org.openecomp.ncomp.sirius.manager.GenericHttpClient; + +import org.apache.log4j.Logger; + +import org.openecomp.logger.EcompLogger; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; + +import org.openecomp.dcae.controller.platform.controller.impl.DcaePlatformControllerImpl; +import org.openecomp.dcae.controller.platform.controller.ControllerPackage; +import org.openecomp.dcae.controller.platform.servers.controller.logging.DcaePlatformControllerOperationEnum; +import org.openecomp.dcae.controller.platform.servers.controller.logging.DcaePlatformControllerMessageEnum; + + + + + + +@SuppressWarnings("unchecked") +public class DcaeDcaePlatformControllerClient extends DcaePlatformControllerImpl { + public static final Logger logger = Logger.getLogger(DcaeDcaePlatformControllerClient.class); + static final EcompLogger ecomplogger = EcompLogger.getEcompLogger(); + public AbstractClient client; + + public DcaeDcaePlatformControllerClient(String file, String name) { + DcaeDcaePlatformController.ecoreSetup(); + client = new GenericHttpClient(file,name); + client.add("/resources", this); + } + + public DcaeDcaePlatformControllerClient(String file, String name1, String name2) { + HighAvailabilityClient client1 = new HighAvailabilityClient(file,name1,name2); + client = client1.all; // requests should be forwarded to all. + client.add("/resources", this); + } + + public DcaeDcaePlatformControllerClient(AbstractClient c) { + client = c; + client.add("/resources", this); + } + + + + @Override + public void deployDescriptor(java.lang.String name) { + EClass c = ControllerPackage.eINSTANCE.getDcaePlatformController(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.REMOTE_deployDescriptor); + + try { + client.operationPath("/resources", c, "deployDescriptor", null, name); + } + catch (Exception e) { + ecomplogger.warn(DcaePlatformControllerMessageEnum.REMOTE_deployDescriptor, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@deployDescriptor: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void refreshDataBus(java.lang.String nameMatch) { + EClass c = ControllerPackage.eINSTANCE.getDcaePlatformController(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.REMOTE_refreshDataBus); + + try { + client.operationPath("/resources", c, "refreshDataBus", null, nameMatch); + } + catch (Exception e) { + ecomplogger.warn(DcaePlatformControllerMessageEnum.REMOTE_refreshDataBus, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@refreshDataBus: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void logs(org.json.JSONObject cx, EList<org.openecomp.ncomp.core.logs.LogMessage> logs) { + EClass c = ControllerPackage.eINSTANCE.getDcaePlatformController(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.REMOTE_logs); + + try { + client.operationPath("/resources", c, "logs", cx != null && cx.has("timeout") ? cx.getLong("timeout") : null, cx,logs); + } + catch (Exception e) { + ecomplogger.warn(DcaePlatformControllerMessageEnum.REMOTE_logs, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@logs: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void metrics(org.json.JSONObject cx, EList<org.openecomp.ncomp.core.metrics.Metric> metrics) { + EClass c = ControllerPackage.eINSTANCE.getDcaePlatformController(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.REMOTE_metrics); + + try { + client.operationPath("/resources", c, "metrics", cx != null && cx.has("timeout") ? cx.getLong("timeout") : null, cx,metrics); + } + catch (Exception e) { + ecomplogger.warn(DcaePlatformControllerMessageEnum.REMOTE_metrics, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@metrics: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void properties(org.json.JSONObject cx, EList<org.openecomp.ncomp.sirius.manager.properties.AbstractProperty> l) { + EClass c = ControllerPackage.eINSTANCE.getDcaePlatformController(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.REMOTE_properties); + + try { + client.operationPath("/resources", c, "properties", cx != null && cx.has("timeout") ? cx.getLong("timeout") : null, cx,l); + } + catch (Exception e) { + ecomplogger.warn(DcaePlatformControllerMessageEnum.REMOTE_properties, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@properties: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public void uploadInfo(org.json.JSONObject cx, EList<org.openecomp.ncomp.sirius.manager.server.ManagementInfo> info) { + EClass c = ControllerPackage.eINSTANCE.getDcaePlatformController(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.REMOTE_uploadInfo); + + try { + client.operationPath("/resources", c, "uploadInfo", cx != null && cx.has("timeout") ? cx.getLong("timeout") : null, cx,info); + } + catch (Exception e) { + ecomplogger.warn(DcaePlatformControllerMessageEnum.REMOTE_uploadInfo, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@uploadInfo: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + + @Override + public EList<org.openecomp.ncomp.core.metrics.DoubleMetric> getValues(org.json.JSONObject cx, java.lang.String path, java.lang.Long start, java.lang.Long end, org.openecomp.ncomp.core.metrics.MetricValueOption option, boolean relativeInterval) { + EClass c = ControllerPackage.eINSTANCE.getDcaePlatformController(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.REMOTE_getValues); + EList<org.openecomp.ncomp.core.metrics.DoubleMetric> res; + try { + res = (EList<org.openecomp.ncomp.core.metrics.DoubleMetric>) client.operationPath("/resources", c, "getValues", cx != null && cx.has("timeout") ? cx.getLong("timeout") : null, cx,path,start,end,option,relativeInterval); + } + catch (Exception e) { + ecomplogger.warn(DcaePlatformControllerMessageEnum.REMOTE_getValues, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@getValues: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + + @Override + public EList<org.openecomp.ncomp.core.metrics.DoubleMetric> getValuesAll(org.json.JSONObject cx, 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) { + EClass c = ControllerPackage.eINSTANCE.getDcaePlatformController(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.REMOTE_getValuesAll); + EList<org.openecomp.ncomp.core.metrics.DoubleMetric> res; + try { + res = (EList<org.openecomp.ncomp.core.metrics.DoubleMetric>) client.operationPath("/resources", c, "getValuesAll", cx != null && cx.has("timeout") ? cx.getLong("timeout") : null, cx,path,metrics,start,end,option,relativeInterval); + } + catch (Exception e) { + ecomplogger.warn(DcaePlatformControllerMessageEnum.REMOTE_getValuesAll, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@getValuesAll: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + + @Override + public EList<org.openecomp.ncomp.core.logs.LogMessage> getMessages(org.json.JSONObject cx, java.lang.String path, java.lang.Long start, java.lang.Long end) { + EClass c = ControllerPackage.eINSTANCE.getDcaePlatformController(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.REMOTE_getMessages); + EList<org.openecomp.ncomp.core.logs.LogMessage> res; + try { + res = (EList<org.openecomp.ncomp.core.logs.LogMessage>) client.operationPath("/resources", c, "getMessages", cx != null && cx.has("timeout") ? cx.getLong("timeout") : null, cx,path,start,end); + } + catch (Exception e) { + ecomplogger.warn(DcaePlatformControllerMessageEnum.REMOTE_getMessages, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@getMessages: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + + @Override + 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) { + EClass c = ControllerPackage.eINSTANCE.getDcaePlatformController(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.REMOTE_getRequestLogger); + org.openecomp.ncomp.sirius.manager.server.LoggerInfo res; + try { + res = (org.openecomp.ncomp.sirius.manager.server.LoggerInfo) client.operationPath("/resources", c, "getRequestLogger", null, userName,action,resourcePath,context); + } + catch (Exception e) { + ecomplogger.warn(DcaePlatformControllerMessageEnum.REMOTE_getRequestLogger, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@getRequestLogger: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + + @Override + public EList<org.openecomp.ncomp.core.function.ValuePair> evaluate(java.lang.String path, org.openecomp.ncomp.core.function.Function function) { + EClass c = ControllerPackage.eINSTANCE.getDcaePlatformController(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.REMOTE_evaluate); + EList<org.openecomp.ncomp.core.function.ValuePair> res; + try { + res = (EList<org.openecomp.ncomp.core.function.ValuePair>) client.operationPath("/resources", c, "evaluate", null, path,function); + } + catch (Exception e) { + ecomplogger.warn(DcaePlatformControllerMessageEnum.REMOTE_evaluate, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@evaluate: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + + @Override + public void update(java.lang.String path, org.openecomp.ncomp.core.function.Function function) { + EClass c = ControllerPackage.eINSTANCE.getDcaePlatformController(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(DcaePlatformControllerOperationEnum.REMOTE_update); + + try { + client.operationPath("/resources", c, "update", null, path,function); + } + catch (Exception e) { + ecomplogger.warn(DcaePlatformControllerMessageEnum.REMOTE_update, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@update: " + e); + } + ecomplogger.recordMetricEventEnd(); + + } + +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeDcaePlatformControllerConsole.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeDcaePlatformControllerConsole.java new file mode 100644 index 0000000..0ad6540 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeDcaePlatformControllerConsole.java @@ -0,0 +1,197 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +// Autogenerated +// Do not edit but extend this class as needed +package org.openecomp.dcae.controller.platform.servers.controller; + + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; + +import org.openecomp.ncomp.sirius.manager.console.Console; +import org.openecomp.ncomp.sirius.manager.AbstractClient; +import org.openecomp.ncomp.sirius.manager.ManagementServerError; + + + +import org.openecomp.dcae.controller.platform.servers.controller.gui.DcaeGuiClientApiConsole; + + +public class DcaeDcaePlatformControllerConsole extends Console { + public static final Logger logger = Logger.getLogger(DcaeDcaePlatformControllerConsole.class); + protected DcaeDcaePlatformControllerClient controller; + + + DcaeControllerClusterConsole cluster; + DcaeControllerVirtualMachineServiceConsole cont; + DcaeGuiClientApiConsole gui; + + + public DcaeDcaePlatformControllerConsole(String filename, String name) { + super(filename, name); + controller = new DcaeDcaePlatformControllerClient(filename,name); + client = controller.client; + + cluster = new DcaeControllerClusterConsole(filename,name); + cont = new DcaeControllerVirtualMachineServiceConsole(filename,name); + gui = new DcaeGuiClientApiConsole(filename,name); + } + + public DcaeDcaePlatformControllerConsole(AbstractClient c) { + controller = new DcaeDcaePlatformControllerClient(c); + client = controller.client; + } + + + public void deployDescriptor(java.lang.String name) { + + try { + controller.deployDescriptor(name); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + + } + + public void refreshDataBus(java.lang.String nameMatch) { + + try { + controller.refreshDataBus(nameMatch); + } + 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)); + } + + } + +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeDcaePlatformControllerProviderTemplate.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeDcaePlatformControllerProviderTemplate.java new file mode 100644 index 0000000..09a439c --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeDcaePlatformControllerProviderTemplate.java @@ -0,0 +1,96 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + +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.ISiriusPlugin; +import org.openecomp.ncomp.sirius.manager.ISiriusServer; +import org.openecomp.ncomp.sirius.function.FunctionUtils; + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; +import org.json.JSONObject; + + + +import java.util.Date; + + +import org.openecomp.ncomp.sirius.manager.server.LoggerInfo; + + +import org.openecomp.ncomp.sirius.manager.server.ServerFactory; + + +import org.openecomp.ncomp.sirius.manager.BasicManagementServerProvider; + + +import org.openecomp.dcae.controller.platform.controller.impl.DcaePlatformControllerImpl; +import org.openecomp.dcae.controller.platform.controller.DcaePlatformController; + + +public class DcaeDcaePlatformControllerProviderTemplate extends BasicManagementServerProvider { + private static final Logger logger = Logger.getLogger(DcaeDcaePlatformControllerProviderTemplate.class); + DcaePlatformController o; + + public DcaeDcaePlatformControllerProviderTemplate(ISiriusServer controller, DcaePlatformController o) { + super(controller, o); + this.o = o; + } + + public void deployDescriptor(java.lang.String name) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void refreshDataBus(java.lang.String nameMatch) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + +public Object handleJson(String userName, String action, String resourcePath, JSONObject json, JSONObject context) { + // TODO Auto-generated method stub + return null; + } + + public Object handleBinary(String userName, String action, String resourcePath, InputStream in) { + // TODO Auto-generated method stub + return null; + } + + + + + + + +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeDcaePlatformControllerServer.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeDcaePlatformControllerServer.java new file mode 100644 index 0000000..2dc725f --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/DcaeDcaePlatformControllerServer.java @@ -0,0 +1,129 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +// Autogenerated +// Do not edit but extend this class as needed +package org.openecomp.dcae.controller.platform.servers.controller; + +import static org.openecomp.ncomp.utils.PropertyUtil.getPropertiesFromClasspath; + +import java.io.IOException; +import java.util.Properties; +import java.util.TimeZone; + +import org.apache.log4j.Logger; +import org.eclipse.emf.ecore.EFactory; + +import org.openecomp.entity.EcompComponent; +import org.openecomp.entity.EcompSubComponent; +import org.openecomp.entity.EcompSubComponentInstance; +import org.openecomp.ncomp.sirius.manager.Jetty8Server; +import org.openecomp.ncomp.sirius.manager.ManagementServer; +import org.openecomp.ncomp.sirius.manager.ISiriusServer; + +import org.openecomp.dcae.controller.platform.controller.DcaePlatformController; + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeControllerFactory; + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeControllerFactory; + +import org.openecomp.dcae.controller.platform.servers.controller.gui.DcaeModelFactory; + + + + + +public class DcaeDcaePlatformControllerServer implements ISiriusServer { + public static final Logger logger = Logger.getLogger(DcaeDcaePlatformControllerServer.class); + String serverPath; + ManagementServer server; + DcaeDcaePlatformController controller; + String directory = "data"; +// LocationControllerApi api ; + Jetty8Server webServer; + DcaeControllerFactory f = new DcaeControllerFactory(this); + + + String clusterPath; + ManagementServer clusterServer; + + String contPath; + ManagementServer contServer; + + String guiPath; + ManagementServer guiServer; + + + public DcaeDcaePlatformControllerServer(String filename) throws IOException { + logger.warn("controller restarting"); + DcaeDcaePlatformController.ecoreSetup(); + props = getPropertiesFromClasspath(filename); + serverPath = (String) props.get("server.dir"); + server = new ManagementServer(f, "DcaePlatformController", serverPath, filename); + server.addFactory(f); + + server.addFactory(new org.openecomp.ncomp.servers.openstack.OsOpenstackFactory(this)); + + + server.addFactory(new org.openecomp.ncomp.servers.openstack.loc.OsLocationFactory(this)); + + + server.addRuntimeFactories(this); + server.start(); + } + public void runWebserver() throws IOException { + controller = (DcaeDcaePlatformController) server.find("/").o; + webServer = new Jetty8Server("controller.properties"); + webServer.add("/resources",server); + + webServer.add("/test",controller); + + webServer.add("/swagger",controller); + + + + EFactory guiFactory = new DcaeModelFactory(this); + guiPath = serverPath + "/gui"; + guiServer = new ManagementServer(guiFactory, "GuiClientApi", guiPath, "gui.properties"); + guiServer.start(); + webServer.add("/gui",guiServer); + + + + logger.info("Joining webserver"); + webServer.join(); + } + static Properties props = null; + public static void main(String []args) throws IOException { + // ALWAYS USE GMT. + TimeZone.setDefault(TimeZone.getTimeZone("GMT")); + + DcaeDcaePlatformControllerServer s = new DcaeDcaePlatformControllerServer("controller.properties"); + s.runWebserver(); + } + public DcaePlatformController getController() { + return controller; + } + 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/gui/DcaeGuiClientApi.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/DcaeGuiClientApi.java new file mode 100644 index 0000000..7fc89db --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/DcaeGuiClientApi.java @@ -0,0 +1,278 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +// Autogenerated +// Do not edit. No need to extend this class. +package org.openecomp.dcae.controller.platform.servers.controller.gui; + + + + + + +import java.io.InputStream; + +import org.openecomp.ncomp.sirius.manager.IRequestHandler; +import org.openecomp.ncomp.sirius.manager.ISwaggerHandler; +import org.openecomp.ncomp.sirius.manager.ISiriusPlugin; +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.logger.EcompLogger; + +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.gui.logging.GuiClientApiOperationEnum; +import org.openecomp.dcae.controller.platform.servers.controller.gui.logging.GuiClientApiMessageEnum; + + + + + + + +import org.openecomp.ncomp.sirius.gui.tools.*; + + + + + +import org.openecomp.ncomp.gwt.siriusportal.model.*; + + + + + +import org.openecomp.ncomp.sirius.manager.Subject; + + + + + +import org.openecomp.ncomp.sirius.manager.ManagementServer; + + + + + +import org.openecomp.ncomp.sirius.manager.server.AbstractManagementServer; + + +import org.openecomp.ncomp.gwt.siriusportal.model.impl.GuiClientApiImpl; + + + +public class DcaeGuiClientApi extends GuiClientApiImpl { + public static final Logger logger = Logger.getLogger(DcaeGuiClientApi.class); + static final EcompLogger ecomplogger = EcompLogger.getEcompLogger(); + public DcaeGuiClientApiProvider controller; + ISiriusServer server; + + public DcaeGuiClientApi(ISiriusServer server) { + this.server = server; + this.controller = new DcaeGuiClientApiProvider(server,this); + } + + public org.openecomp.ncomp.gwt.siriusportal.model.GuiTree getTree() { + org.openecomp.ncomp.gwt.siriusportal.model.GuiTree res = null; + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "getTree", ApiRequestStatus.START, duration_); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(GuiClientApiOperationEnum.getTree); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + res = controller.getTree(); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getTree", ApiRequestStatus.ERROR, duration_); + System.err.println("ERROR: " + e); + ecomplogger.warn(GuiClientApiMessageEnum.getTree, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getTree", ApiRequestStatus.OKAY, duration_); + return res; + } + + public org.openecomp.ncomp.gwt.siriusportal.model.GuiObject getObject(java.lang.String path) { + org.openecomp.ncomp.gwt.siriusportal.model.GuiObject res = null; + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "getObject", ApiRequestStatus.START, duration_,path); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(GuiClientApiOperationEnum.getObject); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + res = controller.getObject(path); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getObject", ApiRequestStatus.ERROR, duration_,path); + System.err.println("ERROR: " + e); + ecomplogger.warn(GuiClientApiMessageEnum.getObject, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getObject", ApiRequestStatus.OKAY, duration_,path); + return res; + } + + public org.openecomp.ncomp.gwt.siriusportal.model.GuiTimeSerie getTimeSerie(java.lang.String path, java.lang.String start, java.lang.String end, java.lang.String duration) { + org.openecomp.ncomp.gwt.siriusportal.model.GuiTimeSerie res = null; + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "getTimeSerie", ApiRequestStatus.START, duration_,path,start,end,duration); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(GuiClientApiOperationEnum.getTimeSerie); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + res = controller.getTimeSerie(path,start,end,duration); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getTimeSerie", ApiRequestStatus.ERROR, duration_,path,start,end,duration); + System.err.println("ERROR: " + e); + ecomplogger.warn(GuiClientApiMessageEnum.getTimeSerie, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getTimeSerie", ApiRequestStatus.OKAY, duration_,path,start,end,duration); + return res; + } + + public org.openecomp.ncomp.gwt.siriusportal.model.GuiTable getTable(java.lang.String path, java.lang.String start, java.lang.String end) { + org.openecomp.ncomp.gwt.siriusportal.model.GuiTable res = null; + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "getTable", ApiRequestStatus.START, duration_,path,start,end); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(GuiClientApiOperationEnum.getTable); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + res = controller.getTable(path,start,end); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getTable", ApiRequestStatus.ERROR, duration_,path,start,end); + System.err.println("ERROR: " + e); + ecomplogger.warn(GuiClientApiMessageEnum.getTable, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getTable", ApiRequestStatus.OKAY, duration_,path,start,end); + return res; + } + + public org.openecomp.ncomp.gwt.siriusportal.model.GuiHtml getHtml(java.lang.String path, java.lang.String start, java.lang.String end) { + org.openecomp.ncomp.gwt.siriusportal.model.GuiHtml res = null; + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "getHtml", ApiRequestStatus.START, duration_,path,start,end); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(GuiClientApiOperationEnum.getHtml); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + res = controller.getHtml(path,start,end); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getHtml", ApiRequestStatus.ERROR, duration_,path,start,end); + System.err.println("ERROR: " + e); + ecomplogger.warn(GuiClientApiMessageEnum.getHtml, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getHtml", ApiRequestStatus.OKAY, duration_,path,start,end); + return res; + } + + public org.openecomp.ncomp.sirius.manager.graph.GuiGraph getGraph(java.lang.String path, java.lang.String start, java.lang.String end) { + org.openecomp.ncomp.sirius.manager.graph.GuiGraph res = null; + long duration_ = 0; + if (server != null) + server.getServer().recordApi(null, this, "getGraph", ApiRequestStatus.START, duration_,path,start,end); + Date now_ = new Date(); + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(GuiClientApiOperationEnum.getGraph); + ecomplogger.setInstanceId(ManagementServer.object2ref(this)); + try { + res = controller.getGraph(path,start,end); + } + catch (Exception e) { + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getGraph", ApiRequestStatus.ERROR, duration_,path,start,end); + System.err.println("ERROR: " + e); + ecomplogger.warn(GuiClientApiMessageEnum.getGraph, e.toString()); + throw e; + } + ecomplogger.recordMetricEventEnd(); + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "getGraph", ApiRequestStatus.OKAY, duration_,path,start,end); + return res; + } + + + + + + + + + public static void ecoreSetup() { + DcaeGuiClientApiProvider.ecoreSetup(); + } + public DcaeGuiClientApiProvider getSomfProvider() { + return controller; + } +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/DcaeGuiClientApiClient.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/DcaeGuiClientApiClient.java new file mode 100644 index 0000000..720cae3 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/DcaeGuiClientApiClient.java @@ -0,0 +1,175 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +// Autogenerated +// Do not edit. No need to extend this class. +package org.openecomp.dcae.controller.platform.servers.controller.gui; + +import org.openecomp.ncomp.sirius.manager.AbstractClient; +import org.openecomp.ncomp.sirius.manager.HighAvailabilityClient; +import org.openecomp.ncomp.sirius.manager.GenericHttpClient; + +import org.apache.log4j.Logger; + +import org.openecomp.logger.EcompLogger; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; + +import org.openecomp.ncomp.gwt.siriusportal.model.impl.GuiClientApiImpl; +import org.openecomp.ncomp.gwt.siriusportal.model.ModelPackage; +import org.openecomp.dcae.controller.platform.servers.controller.gui.logging.GuiClientApiOperationEnum; +import org.openecomp.dcae.controller.platform.servers.controller.gui.logging.GuiClientApiMessageEnum; + + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformController; + + + + +@SuppressWarnings("unchecked") +public class DcaeGuiClientApiClient extends GuiClientApiImpl { + public static final Logger logger = Logger.getLogger(DcaeGuiClientApiClient.class); + static final EcompLogger ecomplogger = EcompLogger.getEcompLogger(); + public AbstractClient client; + + public DcaeGuiClientApiClient(String file, String name) { + DcaeDcaePlatformController.ecoreSetup(); + client = new GenericHttpClient(file,name); + client.add("/gui", this); + } + + public DcaeGuiClientApiClient(String file, String name1, String name2) { + HighAvailabilityClient client1 = new HighAvailabilityClient(file,name1,name2); + client = client1.all; // requests should be forwarded to all. + client.add("/gui", this); + } + + public DcaeGuiClientApiClient(AbstractClient c) { + client = c; + client.add("/resources", this); + } + + + + @Override + public org.openecomp.ncomp.gwt.siriusportal.model.GuiTree getTree() { + EClass c = ModelPackage.eINSTANCE.getGuiClientApi(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(GuiClientApiOperationEnum.REMOTE_getTree); + org.openecomp.ncomp.gwt.siriusportal.model.GuiTree res; + try { + res = (org.openecomp.ncomp.gwt.siriusportal.model.GuiTree) client.operationPath("/gui", c, "getTree", null); + } + catch (Exception e) { + ecomplogger.warn(GuiClientApiMessageEnum.REMOTE_getTree, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@getTree: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + + @Override + public org.openecomp.ncomp.gwt.siriusportal.model.GuiObject getObject(java.lang.String path) { + EClass c = ModelPackage.eINSTANCE.getGuiClientApi(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(GuiClientApiOperationEnum.REMOTE_getObject); + org.openecomp.ncomp.gwt.siriusportal.model.GuiObject res; + try { + res = (org.openecomp.ncomp.gwt.siriusportal.model.GuiObject) client.operationPath("/gui", c, "getObject", null, path); + } + catch (Exception e) { + ecomplogger.warn(GuiClientApiMessageEnum.REMOTE_getObject, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@getObject: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + + @Override + public org.openecomp.ncomp.gwt.siriusportal.model.GuiTimeSerie getTimeSerie(java.lang.String path, java.lang.String start, java.lang.String end, java.lang.String duration) { + EClass c = ModelPackage.eINSTANCE.getGuiClientApi(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(GuiClientApiOperationEnum.REMOTE_getTimeSerie); + org.openecomp.ncomp.gwt.siriusportal.model.GuiTimeSerie res; + try { + res = (org.openecomp.ncomp.gwt.siriusportal.model.GuiTimeSerie) client.operationPath("/gui", c, "getTimeSerie", null, path,start,end,duration); + } + catch (Exception e) { + ecomplogger.warn(GuiClientApiMessageEnum.REMOTE_getTimeSerie, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@getTimeSerie: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + + @Override + public org.openecomp.ncomp.gwt.siriusportal.model.GuiTable getTable(java.lang.String path, java.lang.String start, java.lang.String end) { + EClass c = ModelPackage.eINSTANCE.getGuiClientApi(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(GuiClientApiOperationEnum.REMOTE_getTable); + org.openecomp.ncomp.gwt.siriusportal.model.GuiTable res; + try { + res = (org.openecomp.ncomp.gwt.siriusportal.model.GuiTable) client.operationPath("/gui", c, "getTable", null, path,start,end); + } + catch (Exception e) { + ecomplogger.warn(GuiClientApiMessageEnum.REMOTE_getTable, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@getTable: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + + @Override + public org.openecomp.ncomp.gwt.siriusportal.model.GuiHtml getHtml(java.lang.String path, java.lang.String start, java.lang.String end) { + EClass c = ModelPackage.eINSTANCE.getGuiClientApi(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(GuiClientApiOperationEnum.REMOTE_getHtml); + org.openecomp.ncomp.gwt.siriusportal.model.GuiHtml res; + try { + res = (org.openecomp.ncomp.gwt.siriusportal.model.GuiHtml) client.operationPath("/gui", c, "getHtml", null, path,start,end); + } + catch (Exception e) { + ecomplogger.warn(GuiClientApiMessageEnum.REMOTE_getHtml, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@getHtml: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + + @Override + public org.openecomp.ncomp.sirius.manager.graph.GuiGraph getGraph(java.lang.String path, java.lang.String start, java.lang.String end) { + EClass c = ModelPackage.eINSTANCE.getGuiClientApi(); //foo + ecomplogger.recordMetricEventStart(); + ecomplogger.setOperation(GuiClientApiOperationEnum.REMOTE_getGraph); + org.openecomp.ncomp.sirius.manager.graph.GuiGraph res; + try { + res = (org.openecomp.ncomp.sirius.manager.graph.GuiGraph) client.operationPath("/gui", c, "getGraph", null, path,start,end); + } + catch (Exception e) { + ecomplogger.warn(GuiClientApiMessageEnum.REMOTE_getGraph, e.toString()); + throw new RuntimeException("remote call failed: " + client.getRemote() + "@getGraph: " + e); + } + ecomplogger.recordMetricEventEnd(); + return res; + } + +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/DcaeGuiClientApiConsole.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/DcaeGuiClientApiConsole.java new file mode 100644 index 0000000..1e3b7a6 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/DcaeGuiClientApiConsole.java @@ -0,0 +1,123 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +// Autogenerated +// Do not edit but extend this class as needed +package org.openecomp.dcae.controller.platform.servers.controller.gui; + + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; + +import org.openecomp.ncomp.sirius.manager.console.Console; +import org.openecomp.ncomp.sirius.manager.AbstractClient; +import org.openecomp.ncomp.sirius.manager.ManagementServerError; + + + + +public class DcaeGuiClientApiConsole extends Console { + public static final Logger logger = Logger.getLogger(DcaeGuiClientApiConsole.class); + protected DcaeGuiClientApiClient controller; + + + + + public DcaeGuiClientApiConsole(String filename, String name) { + super(filename, name); + controller = new DcaeGuiClientApiClient(filename,name); + client = controller.client; + + } + + public DcaeGuiClientApiConsole(AbstractClient c) { + controller = new DcaeGuiClientApiClient(c); + client = controller.client; + } + + + public org.openecomp.ncomp.gwt.siriusportal.model.GuiTree getTree() { + org.openecomp.ncomp.gwt.siriusportal.model.GuiTree res = null; + try { + res = controller.getTree(); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + return res; + } + + public org.openecomp.ncomp.gwt.siriusportal.model.GuiObject getObject(java.lang.String path) { + org.openecomp.ncomp.gwt.siriusportal.model.GuiObject res = null; + try { + res = controller.getObject(path); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + return res; + } + + public org.openecomp.ncomp.gwt.siriusportal.model.GuiTimeSerie getTimeSerie(java.lang.String path, java.lang.String start, java.lang.String end, java.lang.String duration) { + org.openecomp.ncomp.gwt.siriusportal.model.GuiTimeSerie res = null; + try { + res = controller.getTimeSerie(path,start,end,duration); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + return res; + } + + public org.openecomp.ncomp.gwt.siriusportal.model.GuiTable getTable(java.lang.String path, java.lang.String start, java.lang.String end) { + org.openecomp.ncomp.gwt.siriusportal.model.GuiTable res = null; + try { + res = controller.getTable(path,start,end); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + return res; + } + + public org.openecomp.ncomp.gwt.siriusportal.model.GuiHtml getHtml(java.lang.String path, java.lang.String start, java.lang.String end) { + org.openecomp.ncomp.gwt.siriusportal.model.GuiHtml res = null; + try { + res = controller.getHtml(path,start,end); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + return res; + } + + public org.openecomp.ncomp.sirius.manager.graph.GuiGraph getGraph(java.lang.String path, java.lang.String start, java.lang.String end) { + org.openecomp.ncomp.sirius.manager.graph.GuiGraph res = null; + try { + res = controller.getGraph(path,start,end); + } + catch (ManagementServerError e) { + System.err.println("ERROR: " + e.getJson().toString(2)); + } + return res; + } + +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/DcaeGuiClientApiProviderTemplate.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/DcaeGuiClientApiProviderTemplate.java new file mode 100644 index 0000000..efdcdab --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/DcaeGuiClientApiProviderTemplate.java @@ -0,0 +1,78 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + +package org.openecomp.dcae.controller.platform.servers.controller.gui; + + + + + +import java.io.InputStream; + +import org.openecomp.ncomp.sirius.manager.IRequestHandler; +import org.openecomp.ncomp.sirius.manager.ISiriusPlugin; +import org.openecomp.ncomp.sirius.manager.ISiriusServer; +import org.openecomp.ncomp.sirius.function.FunctionUtils; + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; +import org.json.JSONObject; + + + +import org.openecomp.ncomp.sirius.gui.tools.*; + + +import org.openecomp.ncomp.gwt.siriusportal.model.*; + + +import org.openecomp.ncomp.sirius.manager.Subject; + + +import org.openecomp.ncomp.sirius.manager.ManagementServer; + + +import org.openecomp.ncomp.sirius.manager.server.AbstractManagementServer; + + +import org.openecomp.ncomp.sirius.manager.BasicGuiClientApiProvider; + + +import org.openecomp.ncomp.gwt.siriusportal.model.impl.GuiClientApiImpl; +import org.openecomp.ncomp.gwt.siriusportal.model.GuiClientApi; + + +public class DcaeGuiClientApiProviderTemplate extends BasicGuiClientApiProvider { + private static final Logger logger = Logger.getLogger(DcaeGuiClientApiProviderTemplate.class); + GuiClientApi o; + + public DcaeGuiClientApiProviderTemplate(ISiriusServer controller, GuiClientApi o) { + super(controller, o); + this.o = o; + } + + + + + + +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/DcaeModelFactory.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/DcaeModelFactory.java new file mode 100644 index 0000000..e2ff048 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/DcaeModelFactory.java @@ -0,0 +1,54 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + +// Autogenerated +// Do not edit. No need to extend this class. +package org.openecomp.dcae.controller.platform.servers.controller.gui; + +import org.eclipse.emf.ecore.EPackage; +import org.apache.log4j.Logger; + +import org.openecomp.ncomp.sirius.manager.ISiriusServer; + +import org.openecomp.ncomp.gwt.siriusportal.model.GuiClientApi; +import org.openecomp.ncomp.gwt.siriusportal.model.ModelPackage; +import org.openecomp.ncomp.gwt.siriusportal.model.impl.ModelFactoryImpl; + +import org.openecomp.dcae.controller.platform.servers.controller.DcaeDcaePlatformControllerServer; + + + +public class DcaeModelFactory extends ModelFactoryImpl { + public static final Logger logger = Logger.getLogger(DcaeModelFactory.class); + ISiriusServer server = null; + @Override + public EPackage getEPackage() { return ModelPackage.eINSTANCE; } + public DcaeModelFactory(ISiriusServer server) { + this.server = server; + } + @Override + public GuiClientApi createGuiClientApi() { + return new DcaeGuiClientApi(server); + } + + + +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/logging/GuiClientApi.properties b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/logging/GuiClientApi.properties new file mode 100644 index 0000000..8705ab8 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/logging/GuiClientApi.properties @@ -0,0 +1,78 @@ + +dummy=\ + null|\ + null|\ + null|\ + null + +getTree=\ + getTree-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +getObject=\ + getObject-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +getTimeSerie=\ + getTimeSerie-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +getTable=\ + getTable-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +getHtml=\ + getHtml-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +getGraph=\ + getGraph-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +REMOTE_getTree=\ + REMOTE-getTree-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_getObject=\ + REMOTE-getObject-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_getTimeSerie=\ + REMOTE-getTimeSerie-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_getTable=\ + REMOTE-getTable-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_getHtml=\ + REMOTE-getHtml-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_getGraph=\ + REMOTE-getGraph-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/logging/GuiClientApiMessageEnum.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/logging/GuiClientApiMessageEnum.java new file mode 100644 index 0000000..9a5d804 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/logging/GuiClientApiMessageEnum.java @@ -0,0 +1,47 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + +package org.openecomp.dcae.controller.platform.servers.controller.gui.logging; + +import com.att.eelf.i18n.EELFResourceManager; +import org.openecomp.logger.EcompMessageEnum; + +public enum GuiClientApiMessageEnum implements EcompMessageEnum { + + dummy, + getTree, + getObject, + getTimeSerie, + getTable, + getHtml, + getGraph, + REMOTE_getTree, + REMOTE_getObject, + REMOTE_getTimeSerie, + REMOTE_getTable, + REMOTE_getHtml, + REMOTE_getGraph; + + static { + EELFResourceManager.loadMessageBundle("org.openecomp.dcae.controller.platform.servers.controller.gui.logging.GuiClientApi"); + } +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/logging/GuiClientApiOperationEnum.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/logging/GuiClientApiOperationEnum.java new file mode 100644 index 0000000..aa3a949 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/gui/logging/GuiClientApiOperationEnum.java @@ -0,0 +1,41 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + +package org.openecomp.dcae.controller.platform.servers.controller.gui.logging; + +import org.openecomp.entity.EcompOperationEnum; + +public enum GuiClientApiOperationEnum implements EcompOperationEnum { + + getTree, + getObject, + getTimeSerie, + getTable, + getHtml, + getGraph, + REMOTE_getTree, + REMOTE_getObject, + REMOTE_getTimeSerie, + REMOTE_getTable, + REMOTE_getHtml, + REMOTE_getGraph; +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/ControllerCluster.properties b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/ControllerCluster.properties new file mode 100644 index 0000000..5866f65 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/ControllerCluster.properties @@ -0,0 +1,30 @@ + +dummy=\ + null|\ + null|\ + null|\ + null + +pushData=\ + pushData-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +receiveData=\ + receiveData-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +REMOTE_pushData=\ + REMOTE-pushData-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_receiveData=\ + REMOTE-receiveData-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/ControllerClusterMessageEnum.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/ControllerClusterMessageEnum.java new file mode 100644 index 0000000..10ec310 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/ControllerClusterMessageEnum.java @@ -0,0 +1,39 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + +package org.openecomp.dcae.controller.platform.servers.controller.logging; + +import com.att.eelf.i18n.EELFResourceManager; +import org.openecomp.logger.EcompMessageEnum; + +public enum ControllerClusterMessageEnum implements EcompMessageEnum { + + dummy, + pushData, + receiveData, + REMOTE_pushData, + REMOTE_receiveData; + + static { + EELFResourceManager.loadMessageBundle("org.openecomp.dcae.controller.platform.servers.controller.logging.ControllerCluster"); + } +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/ControllerClusterOperationEnum.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/ControllerClusterOperationEnum.java new file mode 100644 index 0000000..cece429 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/ControllerClusterOperationEnum.java @@ -0,0 +1,33 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + +package org.openecomp.dcae.controller.platform.servers.controller.logging; + +import org.openecomp.entity.EcompOperationEnum; + +public enum ControllerClusterOperationEnum implements EcompOperationEnum { + + pushData, + receiveData, + REMOTE_pushData, + REMOTE_receiveData; +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/ControllerVirtualMachineService.properties b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/ControllerVirtualMachineService.properties new file mode 100644 index 0000000..d32cf07 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/ControllerVirtualMachineService.properties @@ -0,0 +1,150 @@ + +dummy=\ + null|\ + null|\ + null|\ + null + +deploy=\ + deploy-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +undeploy=\ + undeploy-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +test=\ + test-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +suspend=\ + suspend-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +resume=\ + resume-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +pushManagerConfiguration=\ + pushManagerConfiguration-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +pollManagerConfiguration=\ + pollManagerConfiguration-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +managerConfiguration=\ + managerConfiguration-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +managerOperation=\ + managerOperation-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +updateConfigurationFromPolicy=\ + updateConfigurationFromPolicy-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +runHealthTests=\ + runHealthTests-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +updateDeploymentStatus=\ + updateDeploymentStatus-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +REMOTE_deploy=\ + REMOTE-deploy-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_undeploy=\ + REMOTE-undeploy-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_test=\ + REMOTE-test-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_suspend=\ + REMOTE-suspend-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_resume=\ + REMOTE-resume-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_pushManagerConfiguration=\ + REMOTE-pushManagerConfiguration-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_pollManagerConfiguration=\ + REMOTE-pollManagerConfiguration-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_managerConfiguration=\ + REMOTE-managerConfiguration-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_managerOperation=\ + REMOTE-managerOperation-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_updateConfigurationFromPolicy=\ + REMOTE-updateConfigurationFromPolicy-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_runHealthTests=\ + REMOTE-runHealthTests-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_updateDeploymentStatus=\ + REMOTE-updateDeploymentStatus-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/ControllerVirtualMachineServiceMessageEnum.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/ControllerVirtualMachineServiceMessageEnum.java new file mode 100644 index 0000000..65f5139 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/ControllerVirtualMachineServiceMessageEnum.java @@ -0,0 +1,59 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + +package org.openecomp.dcae.controller.platform.servers.controller.logging; + +import com.att.eelf.i18n.EELFResourceManager; +import org.openecomp.logger.EcompMessageEnum; + +public enum ControllerVirtualMachineServiceMessageEnum implements EcompMessageEnum { + + dummy, + deploy, + undeploy, + test, + suspend, + resume, + pushManagerConfiguration, + pollManagerConfiguration, + managerConfiguration, + managerOperation, + updateConfigurationFromPolicy, + runHealthTests, + updateDeploymentStatus, + REMOTE_deploy, + REMOTE_undeploy, + REMOTE_test, + REMOTE_suspend, + REMOTE_resume, + REMOTE_pushManagerConfiguration, + REMOTE_pollManagerConfiguration, + REMOTE_managerConfiguration, + REMOTE_managerOperation, + REMOTE_updateConfigurationFromPolicy, + REMOTE_runHealthTests, + REMOTE_updateDeploymentStatus; + + static { + EELFResourceManager.loadMessageBundle("org.openecomp.dcae.controller.platform.servers.controller.logging.ControllerVirtualMachineService"); + } +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/ControllerVirtualMachineServiceOperationEnum.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/ControllerVirtualMachineServiceOperationEnum.java new file mode 100644 index 0000000..771b696 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/ControllerVirtualMachineServiceOperationEnum.java @@ -0,0 +1,53 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + +package org.openecomp.dcae.controller.platform.servers.controller.logging; + +import org.openecomp.entity.EcompOperationEnum; + +public enum ControllerVirtualMachineServiceOperationEnum implements EcompOperationEnum { + + deploy, + undeploy, + test, + suspend, + resume, + pushManagerConfiguration, + pollManagerConfiguration, + managerConfiguration, + managerOperation, + updateConfigurationFromPolicy, + runHealthTests, + updateDeploymentStatus, + REMOTE_deploy, + REMOTE_undeploy, + REMOTE_test, + REMOTE_suspend, + REMOTE_resume, + REMOTE_pushManagerConfiguration, + REMOTE_pollManagerConfiguration, + REMOTE_managerConfiguration, + REMOTE_managerOperation, + REMOTE_updateConfigurationFromPolicy, + REMOTE_runHealthTests, + REMOTE_updateDeploymentStatus; +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/DcaeController.properties b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/DcaeController.properties new file mode 100644 index 0000000..b8275ac --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/DcaeController.properties @@ -0,0 +1,24 @@ + +HEALTHCHECK_SERVICE_FAILED=\ + DCAE-CONTROLLER-HEALTHCHECK-SERVICE-FAILED-5001W|\ + {0}|\ + Contact Tier 4. This is a software bug.|\ + Heath Check on the service level fails. + +POLICY_POLLING_FAILED=\ + DCAE-CONTROLLER-POLICY-POLLING-FAILED-5001W|\ + {0} {1}|\ + Contact Tier 4. This is a software bug.|\ + Police Polling on the service level fails. + +DATABUS_POLLING_FAILED=\ + DCAE-CONTROLLER-DATABUS-POLLING-FAILED-5001W|\ + {0}|\ + Contact Tier 4. This is a software bug.|\ + Databus Polling on the service level fails. + +CLUSTER_DATA_REPLICATION_FAILED=\ + DCAE-CONTROLLER-CLUSTER_DATA_REPLICATION-FAILED-5001W|\ + {0}|\ + Contact Tier 4. This is a software bug.|\ + Data Replication fails. diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/DcaeControllerMessageEnum.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/DcaeControllerMessageEnum.java new file mode 100644 index 0000000..f026d66 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/DcaeControllerMessageEnum.java @@ -0,0 +1,38 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + +package org.openecomp.dcae.controller.platform.servers.controller.logging; + +import com.att.eelf.i18n.EELFResourceManager; +import org.openecomp.logger.EcompMessageEnum; + +public enum DcaeControllerMessageEnum implements EcompMessageEnum { + + HEALTHCHECK_SERVICE_FAILED, + POLICY_POLLING_FAILED, + DATABUS_POLLING_FAILED, + CLUSTER_DATA_REPLICATION_FAILED; + + static { + EELFResourceManager.loadMessageBundle("org.openecomp.dcae.controller.platform.servers.controller.logging.DcaeController"); + } +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/DcaeControllerOperationEnum.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/DcaeControllerOperationEnum.java new file mode 100644 index 0000000..44c7454 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/DcaeControllerOperationEnum.java @@ -0,0 +1,33 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + +package org.openecomp.dcae.controller.platform.servers.controller.logging; + +import org.openecomp.entity.EcompOperationEnum; + +public enum DcaeControllerOperationEnum implements EcompOperationEnum { + + HEALTHCHECK, + POLICY_POLLING, + DATABUS_POLLING, + CLUSTER_DATA_REPLICATION; +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/DcaePlatformController.properties b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/DcaePlatformController.properties new file mode 100644 index 0000000..a426ec8 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/DcaePlatformController.properties @@ -0,0 +1,150 @@ + +dummy=\ + null|\ + null|\ + null|\ + null + +logs=\ + logs-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +metrics=\ + metrics-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +properties=\ + properties-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +uploadInfo=\ + uploadInfo-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +getValues=\ + getValues-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +getValuesAll=\ + getValuesAll-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +getMessages=\ + getMessages-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +getRequestLogger=\ + getRequestLogger-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +evaluate=\ + evaluate-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +update=\ + update-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +deployDescriptor=\ + deployDescriptor-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +refreshDataBus=\ + refreshDataBus-FAILED-5001W|\ + {0}|\ + null|\ + Operation Failed with Exception + +REMOTE_logs=\ + REMOTE-logs-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_metrics=\ + REMOTE-metrics-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_properties=\ + REMOTE-properties-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_uploadInfo=\ + REMOTE-uploadInfo-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_getValues=\ + REMOTE-getValues-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_getValuesAll=\ + REMOTE-getValuesAll-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_getMessages=\ + REMOTE-getMessages-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_getRequestLogger=\ + REMOTE-getRequestLogger-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_evaluate=\ + REMOTE-evaluate-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_update=\ + REMOTE-update-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_deployDescriptor=\ + REMOTE-deployDescriptor-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception + +REMOTE_refreshDataBus=\ + REMOTE-refreshDataBus-FAILED-5001W|\ + {0}|\ + null|\ + Remote Operation Failed with Exception diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/DcaePlatformControllerMessageEnum.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/DcaePlatformControllerMessageEnum.java new file mode 100644 index 0000000..973543f --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/DcaePlatformControllerMessageEnum.java @@ -0,0 +1,59 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + +package org.openecomp.dcae.controller.platform.servers.controller.logging; + +import com.att.eelf.i18n.EELFResourceManager; +import org.openecomp.logger.EcompMessageEnum; + +public enum DcaePlatformControllerMessageEnum implements EcompMessageEnum { + + dummy, + logs, + metrics, + properties, + uploadInfo, + getValues, + getValuesAll, + getMessages, + getRequestLogger, + evaluate, + update, + deployDescriptor, + refreshDataBus, + REMOTE_logs, + REMOTE_metrics, + REMOTE_properties, + REMOTE_uploadInfo, + REMOTE_getValues, + REMOTE_getValuesAll, + REMOTE_getMessages, + REMOTE_getRequestLogger, + REMOTE_evaluate, + REMOTE_update, + REMOTE_deployDescriptor, + REMOTE_refreshDataBus; + + static { + EELFResourceManager.loadMessageBundle("org.openecomp.dcae.controller.platform.servers.controller.logging.DcaePlatformController"); + } +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/DcaePlatformControllerOperationEnum.java b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/DcaePlatformControllerOperationEnum.java new file mode 100644 index 0000000..f5e0562 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/main/sirius-gen/org/openecomp/dcae/controller/platform/servers/controller/logging/DcaePlatformControllerOperationEnum.java @@ -0,0 +1,53 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + + +package org.openecomp.dcae.controller.platform.servers.controller.logging; + +import org.openecomp.entity.EcompOperationEnum; + +public enum DcaePlatformControllerOperationEnum implements EcompOperationEnum { + + logs, + metrics, + properties, + uploadInfo, + getValues, + getValuesAll, + getMessages, + getRequestLogger, + evaluate, + update, + deployDescriptor, + refreshDataBus, + REMOTE_logs, + REMOTE_metrics, + REMOTE_properties, + REMOTE_uploadInfo, + REMOTE_getValues, + REMOTE_getValuesAll, + REMOTE_getMessages, + REMOTE_getRequestLogger, + REMOTE_evaluate, + REMOTE_update, + REMOTE_deployDescriptor, + REMOTE_refreshDataBus; +} diff --git a/dcae-controller-core/dcae-controller-platform-server/src/test/groovy/policy.groovy b/dcae-controller-core/dcae-controller-platform-server/src/test/groovy/policy.groovy new file mode 100644 index 0000000..58744b0 --- /dev/null +++ b/dcae-controller-core/dcae-controller-platform-server/src/test/groovy/policy.groovy @@ -0,0 +1,21 @@ + +/*- + * ============LICENSE_START========================================== + * OPENECOMP - DCAE + * =================================================================== + * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + */ + |