diff options
author | lj1412 <lji@research.att.com> | 2017-02-14 15:11:44 +0000 |
---|---|---|
committer | lj1412 <lji@research.att.com> | 2017-02-14 15:11:46 +0000 |
commit | 033f0c30154107ddf36cd682c860e95025bf00b0 (patch) | |
tree | 4113f2053aac75642c51b11bfae9a0a608c1ed72 /ncomp-sirius-manager-agent-server | |
parent | f6e50f2cec6365ea71696c58a96aa923eb3a1a10 (diff) |
Init ncomp.sirius.manager
Change-Id: I6691ecd21a942c96cb20cf3baa297e4b2dc7f970
Signed-off-by: lj1412 <lji@research.att.com>
Diffstat (limited to 'ncomp-sirius-manager-agent-server')
41 files changed, 3157 insertions, 0 deletions
diff --git a/ncomp-sirius-manager-agent-server/.classpath b/ncomp-sirius-manager-agent-server/.classpath new file mode 100644 index 0000000..d2d34b3 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/.classpath @@ -0,0 +1,27 @@ +<?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="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/ncomp-sirius-manager-agent-server/.gitignore b/ncomp-sirius-manager-agent-server/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/ncomp-sirius-manager-agent-server/.project b/ncomp-sirius-manager-agent-server/.project new file mode 100644 index 0000000..e8e8aee --- /dev/null +++ b/ncomp-sirius-manager-agent-server/.project @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>ncomp-sirius-manager-agent-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/ncomp-sirius-manager-agent-server/.settings/org.eclipse.core.resources.prefs b/ncomp-sirius-manager-agent-server/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/<project>=UTF-8 diff --git a/ncomp-sirius-manager-agent-server/.settings/org.eclipse.jdt.core.prefs b/ncomp-sirius-manager-agent-server/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..4ede96d --- /dev/null +++ b/ncomp-sirius-manager-agent-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/ncomp-sirius-manager-agent-server/.settings/org.eclipse.jdt.groovy.core.prefs b/ncomp-sirius-manager-agent-server/.settings/org.eclipse.jdt.groovy.core.prefs new file mode 100644 index 0000000..ae98fea --- /dev/null +++ b/ncomp-sirius-manager-agent-server/.settings/org.eclipse.jdt.groovy.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +groovy.compiler.level=24 diff --git a/ncomp-sirius-manager-agent-server/.settings/org.eclipse.m2e.core.prefs b/ncomp-sirius-manager-agent-server/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/ncomp-sirius-manager-agent-server/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/ncomp-sirius-manager-agent-server/LICENSE.txt b/ncomp-sirius-manager-agent-server/LICENSE.txt new file mode 100644 index 0000000..30471b5 --- /dev/null +++ b/ncomp-sirius-manager-agent-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/ncomp-sirius-manager-agent-server/META-INF/MANIFEST.MF b/ncomp-sirius-manager-agent-server/META-INF/MANIFEST.MF new file mode 100644 index 0000000..1f28bfc --- /dev/null +++ b/ncomp-sirius-manager-agent-server/META-INF/MANIFEST.MF @@ -0,0 +1,15 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: ncomp-sirius-manager-agent-server +Bundle-SymbolicName: ncomp-sirius-manager-agent-server +Bundle-Version: 0.1.0.qualifier +Export-Package: org.openecomp.ncomp.sirius.manager.agent.server.tools, + org.openecomp.ncomp.sirius.manager.agent.servers.monitoring +Require-Bundle: ncomp-core-types, + ncomp-sirius-manager-model, + ncomp-sirius-manager-server, + ncomp-sirius-manager-console, + ncomp-sirius-manager-generator, + ncomp-utils-java;bundle-version="0.1.0", + ncomp-sirius-manager-agent-model;bundle-version="0.1.0", + ncomp-utils-java-extra;bundle-version="0.1.0" diff --git a/ncomp-sirius-manager-agent-server/build.properties b/ncomp-sirius-manager-agent-server/build.properties new file mode 100644 index 0000000..80bc250 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/build.properties @@ -0,0 +1,6 @@ +source.. = src/main/java/,\ + src/main/resources/,\ + src/test/java/,\ + src/test/resources/ +bin.includes = META-INF/,\ + . diff --git a/ncomp-sirius-manager-agent-server/pom.xml b/ncomp-sirius-manager-agent-server/pom.xml new file mode 100644 index 0000000..cd4de2a --- /dev/null +++ b/ncomp-sirius-manager-agent-server/pom.xml @@ -0,0 +1,169 @@ +<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.ncomp.sirius.manager</groupId> + <artifactId>ncomp-sirius-manager-agent-server</artifactId> + <parent> + <groupId>org.openecomp.ncomp.sirius.manager</groupId> + <artifactId>ncomp-sirius-manager-base</artifactId> + <version>0.1.0-SNAPSHOT</version> + <relativePath>../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</excludeGroupIds> + <scope>provided</scope> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <version>2.6</version> + <executions> + <execution> + <id>copy-version</id> + <goals> + <goal>copy-resources</goal> + </goals> + <phase>validate</phase> + <configuration> + <outputDirectory>${basedir}/target/versions</outputDirectory> + <resources> + <resource> + <directory>src/main/resources/versions</directory> + <includes> + <include>version.properties</include> + </includes> + <filtering>true</filtering> + </resource> + </resources> + </configuration> + </execution> + <execution> + <id>copy-resources</id> + <goals> + <goal>copy-resources</goal> + </goals> + <phase>validate</phase> + <configuration> + <outputDirectory>${basedir}/target/etc/bvc-extensions</outputDirectory> + <resources> + <resource> + <directory>src/main/resources/etc/bvc-extensions</directory> + <includes> + <include>feature_config_template.cfg</include> + <include>feature_custom.install</include> + </includes> + <filtering>true</filtering> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>org.openecomp.ncomp.sirius.manager</groupId> + <artifactId>ncomp-sirius-manager-agent-model</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.ncomp.utils</groupId> + <artifactId>ncomp-utils-java-extra</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> +</project> diff --git a/ncomp-sirius-manager-agent-server/src/assembly/assemble_zip.xml b/ncomp-sirius-manager-agent-server/src/assembly/assemble_zip.xml new file mode 100644 index 0000000..4229587 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/assembly/assemble_zip.xml @@ -0,0 +1,61 @@ +<!-- 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>ncomp-sirius-manager-agent-server-${project.artifactId}.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/ncomp-sirius-manager-agent-server/src/main/java/org/openecomp/ncomp/sirius/manager/agent/server/tools/Generator.java b/ncomp-sirius-manager-agent-server/src/main/java/org/openecomp/ncomp/sirius/manager/agent/server/tools/Generator.java new file mode 100644 index 0000000..f09b110 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/java/org/openecomp/ncomp/sirius/manager/agent/server/tools/Generator.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============================================ + */ + +package org.openecomp.ncomp.sirius.manager.agent.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.ncomp.sirius.manager.agent.monitoring.MonitoringFactory;
+
+
+public class Generator {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ @SuppressWarnings("unused")
+ MonitoringFactory f = MonitoringFactory.eINSTANCE;
+ EObject o = MonitoringFactory.eINSTANCE.createSiriusManagerAgentServer();
+ EPackage p = o.eClass().getEPackage();
+ String dir = p.getNsURI().replace(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("Agent");
+ m.setPluginName(p.getNsURI());
+ m.setName("SiriusManagerAgentServer");
+ m.setTitle("SiriusManagerAgentServer");
+ ControllerGenerator g = new ControllerGenerator(o,m);
+ g.setEnableIRequestHandler(false);
+ g.setEnableISiriusPlugin(true);
+ EObject gui = ModelFactory.eINSTANCE.createGuiClientApi();
+ g.addObject("gui",gui,m);
+ EObject e = org.openecomp.ncomp.sirius.manager.server.ServerFactory.eINSTANCE.createSouthBoundApi();
+ g.addObject("south",e,m);
+ //g.addFactory("org.openecomp.ncomp.sirius.servers.openstack.OsOpenstackFactory");
+ //g.enableDrools();
+ g.generate(dir);
+ g.generateScripts("src/main/server-gen/bin","sirius-manager-agent-server");
+ }
+
+
+}
diff --git a/ncomp-sirius-manager-agent-server/src/main/java/org/openecomp/ncomp/sirius/manager/agent/server/tools/MonitoringUtil.groovy b/ncomp-sirius-manager-agent-server/src/main/java/org/openecomp/ncomp/sirius/manager/agent/server/tools/MonitoringUtil.groovy new file mode 100644 index 0000000..657d3dd --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/java/org/openecomp/ncomp/sirius/manager/agent/server/tools/MonitoringUtil.groovy @@ -0,0 +1,438 @@ + +/*- + * ============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.ncomp.sirius.manager.agent.server.tools + +import java.io.File; +import java.util.TimeZone; + +import groovy.io.FileType + +import java.util.regex.Pattern; + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.BasicEList +import org.eclipse.emf.common.util.EList +import org.eclipse.emf.ecore.EClass +import org.eclipse.emf.ecore.EAttribute + +import org.openecomp.ncomp.core.logs.LogLevel; +import org.openecomp.ncomp.core.logs.LogsFactory; +import org.openecomp.ncomp.core.logs.LogMessage +import org.openecomp.ncomp.core.logs.LogSeverity; +import org.openecomp.ncomp.core.metrics.Metric +import org.openecomp.ncomp.core.metrics.MetricsFactory +import org.openecomp.ncomp.core.metrics.StringMetric +import org.openecomp.ncomp.sirius.manager.HighAvailabilityClient +import org.openecomp.ncomp.sirius.manager.ManagementServer +import org.openecomp.ncomp.sirius.manager.agent.collectd.CollectdFactory; +import org.openecomp.ncomp.sirius.manager.agent.collectd.CollectdPackage; +import org.openecomp.ncomp.sirius.manager.agent.servers.monitoring.south.AgentSouthBoundApiClient +import org.openecomp.ncomp.sirius.manager.ModuleReporter; +import org.openecomp.ncomp.sirius.manager.model.* +import org.openecomp.ncomp.sirius.manager.properties.PropertiesFactory; +import org.openecomp.ncomp.sirius.manager.properties.Property +import org.openecomp.ncomp.utils.extra.FileTail +import org.openecomp.ncomp.utils.extra.FileTail.NewLineHandler +import org.openecomp.ncomp.webservice.utils.DateUtils; +import org.openecomp.ncomp.sirius.manager.logs.LogMessageSuppressor +import org.openecomp.ncomp.sirius.manager.logs.LogMessageSuppressor.ILogMessageHandler + +class MonitoringUtil implements NewLineHandler, ILogMessageHandler { + public static final Logger logger = Logger.getLogger(MonitoringUtil.class); + Properties props + def format = "/var/lib/collectd/csv/*/*/.*-%Y-%m-%d" + def directory = "data" + def scanFreq = null + def scanNewFreq = null + def scanDuration = null + long reportFreq = DateUtils.stringToDuration("1min") + long sendFreq = DateUtils.stringToDuration("30sec"); + LogMessageSuppressor logSup = new LogMessageSuppressor(this,300*1000) + AgentSouthBoundApiClient api + def MonitoringUtil(ManagementServer s) { + logger.warn("monitor restarting") + api = new AgentSouthBoundApiClient("monitoring.properties", "lc1","lc2") + props = s.props + def donemodule = [:] + props.keySet().each { k -> +// System.err.println "key = $k -> ${props.get(k)}" + switch (k) { + case ~/commands\..*\.command/: + def a = k.split("\\.") + def x = [name:a[1]] + x["command"] = props.get(k) + x["timeout"] = Long.parseLong(props.getProperty("commands.${x.name}.timeout","60000")) + x["freq"] = Long.parseLong(props.getProperty("commands.${x.name}.freq","3600000")) + commands += [x] + break; + case ~/logs\..*\.file/: + def a = k.split("\\.") + def x = [name:a[1]] + x["file"] = props.get(k) + x["regexp"] = Pattern.compile(props.getProperty("logs.${x.name}.regexp",".*")) + x["path"] = props.getProperty("logs.${x.name}.path","") + x["sev"] = LogSeverity.get(props.getProperty("logs.${x.name}.severity","UNKNOWN")) + if (x["sev"] == null) x["sev"] = LogSeverity.UNKNOWN + x["level"] = LogLevel.get(props.getProperty("logs.${x.name}.level","INFO")) + if (x["level"] == null) x["level"] = LogLevel.UNKNOWN + try {x["levelField"] = Integer.parseInt(props.getProperty("logs.${x.name}.levelField")) } catch (e) {} + logs += [x] + break; + case ~/module\.[^.]*\.(file|jar|command)/: + def a = k.split("\\.") + def x = [name:a[1], submodules:[]] + x["file"] = props.getProperty("module.${x.name}.file",null) + x["jarName"] = props.getProperty("module.${x.name}.jar",null) + x["command"] = props.getProperty("module.${x.name}.command",null) + x["version"] = props.getProperty("module.${x.name}.version",'${version} ${build.time}') + modules += [x] + name2module[x.name] = x + break; + } + } + props.keySet().each { k -> +// System.err.println "key = $k -> ${props.get(k)}" + switch (k) { + case ~/module\..*\.submodule\..*\.(file|jar|command|version)/: + def a = k.split("\\.") + def x = [name:a[3]] + def m = name2module[a[1]] + if (m == null) { logger.warn "No module for submodule: $k"; return } + def prefix = "module.${m.name}.submodule.${x.name}" + if (donemodule[prefix] != null) return + donemodule[prefix] = 1 + x["file"] = props.getProperty("${prefix}.file",null) + x["jarName"] = props.getProperty("${prefix}.jar",null) + x["command"] = props.getProperty("${prefix}.command",null) + x["version"] = props.getProperty("${prefix}.version",'${version} ${build.time}') + m.submodules += x + System.err.println "Adding submodule $prefix $x" + break; + } + } + logger.info("logs = $logs") + logger.info("commands = $commands") + logger.info("modules = $modules") + } + def commands = [] + def logs = [] + def modules = [] + def name2module = [:] + def void run() { + modules.each { m -> + ModuleReporter r = new ModuleReporter(api,m.name,m.jarName,m.file,m.command,m.version); + m.submodules.each { m1 -> + r.addSubmodule(m1.name,m1.jarName,m1.file,m1.command,m1.version); + } + r.start(); + } + Thread.start("run commands") { + try { + while (true) { + runCommands() + sleep 60000 // sleep a minute + } + } + catch (e) { + logger.fatal("run commands thread DIED: $e") + } + } + new FileTail(format, directory, scanFreq, scanNewFreq, scanDuration, this, null); + logs.each{ x -> + new FileTail(x.file, "$directory/logs/$x.name", "10sec", this, x); + } + } + def lastRun = [:] + def void runCommands() { + def dirName = "commandOutputs" + def dir = new File(dirName) + dir.deleteDir() + dir.mkdirs() + long now = new Date().time + commands.each { c -> + if (lastRun[c.name] && lastRun[c.name] + c.freq > now) return + lastRun[c.name] = now + def sout = new StringBuffer() + def serr = new StringBuffer() + def cmd = "$c.command ${dir.getAbsolutePath()}" + logger.info("running $cmd") + def proc = cmd.execute() + proc.consumeProcessOutput(sout, serr) + proc.waitForOrKill(c.timeout) + if (sout.toString() != "") logger.info("output: $sout") + if (serr.toString() != "") logger.warn("error : $serr") + } + EList<Property> propertyList = new BasicEList<Property>() + dir.eachFileRecurse (FileType.FILES) { File file -> + Property x = PropertiesFactory.eINSTANCE.createProperty() + x.name = file.absolutePath.substring(dir.absolutePath.length()) + x.value = file.text + propertyList += x + } + if (propertyList.size() > 0) + api.properties(null,propertyList) + // Note this information is getting handled in the BSA Controller updateProperties + } + static main(args) { + // ALWAYS USE GMT. + TimeZone.setDefault(TimeZone.getTimeZone("GMT")); + // scan collectd data and forwards it to location controller. + logger.warn "Starting server" + def agent = new MonitoringUtil() +// agent.test() + agent.run() + } + + void test() { + def f = [ + "/var/lib/collectd/csv/bsa-blade3/memory/memory-buffered-2013-08-29", + "/var/lib/collectd/csv/bsa-blade3/df/df-ndata2-2013-08-29", + "/var/lib/collectd/csv/bsa-blade3/disk-nbd15/disk_merged-2013-08-29", + "/var/lib/collectd/csv/bsa-blade3/interface/if_packets-vnet0-2013-08-29", + "/var/lib/collectd/csv/instance-0000052a/libvirt/disk_octets-vdb-2013-08-29", + '/var/lib/collectd/csv/instance-0000052a/libvirt/virt_cpu_total-2013-08-29', + "/var/lib/collectd/csv/instance-0000052a/libvirt/if_packets-vnet3-2013-08-29", + "/var/lib/collectd/csv/HORIZON/libvirt/disk_ops-vda-2013-10-10", + ] + f.each { + println "#"*10 + it + new BsaMonitoringAgentFileInfo(it) + } + } + def m = [:] + EList<Metric> metrics = new BasicEList<Metric>() + EList<LogMessage> logmessages = new BasicEList<LogMessage>() + Date lastReport = new Date() + def void uploadInfo() { + Date now = new Date() + if (lastReport.getTime() + sendFreq > now.getTime()) return + synchronized (this) { + try { + if (metrics.size()>0) { + logger.info "Sending ${metrics.size()} metrics" + api.metrics(null,metrics); + } + // Note this information is getting handled in the BSA Controller updateMetrics + } + catch (e) { + logger.error "Sending metrics failed: $e" + } + metrics.clear() + try { + if (logmessages.size()>0) { + logger.info "Sending ${logmessages.size()} logmessages" + api.logs(null,logmessages); + } + // Note this information is getting handled in the BSA Controller updateLogs + } + catch (e) { + logger.error "Sending logmessages failed: $e" + } + logmessages.clear() + lastReport = now; + } + } + @Override + public void newLine(String file, String line, Object context) { + Date now = new Date() + uploadInfo() +// logger.info "new line: $file $line $context" + if (context != null) { + newLogLine(file,line,context) + return + } + BsaMonitoringAgentFileInfo i = m[file] + if (i == null) { + i = new BsaMonitoringAgentFileInfo(file) + m[file] = i + } + if (i.ignore) return + String[] a = line.split(",") + if (a[0] == "epoch") return + long t = Long.parseLong(a[0].split("\\.")[0]) + if (t*1000 - reportFreq < i.lastUpdate.getTime()) return + i.metrics.each { m -> + StringMetric x = MetricsFactory.eINSTANCE.createStringMetric() + if (a.length <= m.col) { + logger.error("bad line: $file: $line $m") + } + x.value = a[m.col] + x.metricName = m.name + x.resourceName = i.resource + x.time = t*1000 + synchronized (this) { metrics += x } + } + i.lastUpdate = now + } + + @Override + public void fixFilePermissions(File file) { + def path = file.getAbsolutePath() + //println "Trying to make $path readable: ${file.canRead()}" + def cmd = "bin/root_wrapper.sh fixFilePermissions $path" + def sout = new StringBuffer() + def serr = new StringBuffer() + logger.info("running $cmd") + def proc = cmd.execute() + proc.consumeProcessOutput(sout, serr) + proc.waitForOrKill(10000) + if (sout.toString() != "") logger.info("output: $sout") + if (serr.toString() != "") logger.warn("error : $serr") + //println "After try $path readable: ${file.canRead()}" + } + + class BsaMonitoringAgentFileInfo { + String resource = "/collectd" + def metrics = [] + boolean ignore = false + Date lastUpdate = new Date(0) + static CollectdPackage p = CollectdPackage.eINSTANCE + public BsaMonitoringAgentFileInfo(String s) { + String[] a = s.split("/") + def host = a[a.length-3] + def plugin = a[a.length-2] + def index = a[a.length-1] + index = index.substring(0,index.length()-11) + switch (plugin) { + case "libvirt": + String[] aa = host.split("-") + resource = "/collectd/instances/$host" + setup(p.collectdKvmInstance,plugin,index) + break + case "memory": + resource = "/collectd/memory" + setup(p.collectdMemory,plugin,index.replace("memory-", "")) + break + case "swap": + resource = "/collectd/swap" + setup(p.collectdMemory,plugin,index.replace("swap-", "")) + break + case "processes": + resource = "/collectd/processes" + setup(p.collectdProcesses,plugin,index.replace("ps_state-", "")) + break + case "load": + case "contextswitch": + case "entropy": + case "interface": + case "df": + setup(p.collectdServer,plugin,index) + break + case "vmem": + resource = "/collectd/vmem" + def index1 = index.replaceFirst("vmpage_.*-", "") + index1 = index1.replace("vmpage_faults","faults") + setup(p.collectdVmem,plugin,index1, index1=="dirty" || index1=="writeback") +// System.err.println "resource=$resource metrics=$metrics index=$index index1=$index1" + break + case ~/irq/: + case ~/cpu-.*/: ignore = true; break + case ~/disk-.*/: + String[] aa = plugin.split("-") + resource = "/collectd/disks/${aa[1]}" + setup(p.collectdDisk,plugin,index) + break + default: logger.warn "Unknown plugin $plugin" + } + // println "$s" + // println "host=$host plugin=$plugin index=$index" + // println "$resource $metrics" + } + void setup(EClass eClass,String p, String i, boolean exactMatch = false) { + def j = 1 + eClass.getEAllAttributes().each { attr -> + if (attr.name == "name") return + if (attr.name == "lastPolled") return + if (attr.name == "lastChanged") return + if (attr.name == "created") return + if ((!exactMatch && attr.name.startsWith(i)) + || (attr.name == i)) + metrics += [ name : attr.name, col : j++] + } + String[] a = i.split("-") + switch (i) { + case ~/df.*/: + if (a.length==1) break + def e = eClass.getEStructuralFeature("filesystems") + resource = "${resource}/$e.name/${a[1]}" + setup(e.eType,p,"") + break + case ~/if_.*/: + if (a.length==1) break + def e = eClass.getEStructuralFeature("interfaces") + resource = "${resource}/interfaces/${a[1]}" + setup(e.eType,p,a[0]) + break + case ~/disk_.*/: + if (a.length==1) break + def e = eClass.getEStructuralFeature("disks") + resource = "${resource}/disks/${a[1]}" + setup(e.eType,p,a[0]) + break + } + } + } + def newLogLine(String file, String line,x) { + Pattern p = x.regexp + if (!p.matcher(line).find()) return + if (line.contains("Logfile reset")) return + if (line.contains("New line from file")) return + //println "$file $line $x" + LogMessage log = LogsFactory.eINSTANCE.createLogMessage() + log.time = new Date().getTime(); + log.resourceName = "$x.path/$x.name" + log.severity = x.sev + log.level = x.level + if (x["levelField"] != null) { + try { + def i = x["levelField"] + def a = line.split(" +",i+2) + log.level = LogLevel.get(a[i].toUpperCase()) + line = a[i+1] + } catch (e) {print e} + } + log.message = line + fixLog(log,"path","resourceName") + fixLog(log,"sev","severity") + logSup.add(log) + } + def fixLog (LogMessage log,s,a) { + def p = Pattern.compile(" $s=\\{(.*?)\\}") + def m = p.matcher(log.message) + if (m.find()) { + switch (a) { + case "severity": log[a] = LogSeverity.get(m.group(1)); break + default: log[a] = m.group(1) + } + log.message = m.replaceAll("") + } + } + @Override + public void handleLog(LogMessage m) { + synchronized (this) { + logmessages += m + } + } + + +} + diff --git a/ncomp-sirius-manager-agent-server/src/main/java/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentSiriusManagerAgentServerProvider.java b/ncomp-sirius-manager-agent-server/src/main/java/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentSiriusManagerAgentServerProvider.java new file mode 100644 index 0000000..a855d5a --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/java/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentSiriusManagerAgentServerProvider.java @@ -0,0 +1,56 @@ + +/*- + * ============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.ncomp.sirius.manager.agent.servers.monitoring; + +import org.openecomp.ncomp.sirius.manager.ISiriusServer; +import org.apache.log4j.Logger; +import org.openecomp.ncomp.sirius.manager.BasicManagementServerProvider; +import org.openecomp.ncomp.sirius.manager.agent.monitoring.SiriusManagerAgentServer; +import org.openecomp.ncomp.sirius.manager.agent.server.tools.MonitoringUtil; + +public class AgentSiriusManagerAgentServerProvider extends + BasicManagementServerProvider { + @SuppressWarnings("unused") + private static final Logger logger = Logger + .getLogger(AgentSiriusManagerAgentServerProvider.class); + SiriusManagerAgentServer o; + @SuppressWarnings("unused") + private MonitoringUtil util; + + public AgentSiriusManagerAgentServerProvider(ISiriusServer controller, + SiriusManagerAgentServer o) { + super(controller, o); + this.o = o; + } + + public void start() { + + util = new MonitoringUtil(controller.getServer()); + util.run(); + } + + public static void ecoreSetup() { + // TODO Auto-generated method stub + + } + +} diff --git a/ncomp-sirius-manager-agent-server/src/main/java/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/gui/AgentGuiClientApiProvider.java b/ncomp-sirius-manager-agent-server/src/main/java/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/gui/AgentGuiClientApiProvider.java new file mode 100644 index 0000000..aa0ae57 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/java/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/gui/AgentGuiClientApiProvider.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.ncomp.sirius.manager.agent.servers.monitoring.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 AgentGuiClientApiProvider extends BasicGuiClientApiProvider { + private static final Logger logger = Logger.getLogger(AgentGuiClientApiProvider.class); + GuiClientApi o; + + public AgentGuiClientApiProvider(ISiriusServer controller, GuiClientApi o) { + super(controller, o); + this.o = o; + } + + + + + + public static void ecoreSetup() { + // TODO Auto-generated method stub + + } + + +} diff --git a/ncomp-sirius-manager-agent-server/src/main/java/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/south/AgentSouthBoundApiProvider.java b/ncomp-sirius-manager-agent-server/src/main/java/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/south/AgentSouthBoundApiProvider.java new file mode 100644 index 0000000..b1eb15b --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/java/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/south/AgentSouthBoundApiProvider.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============================================ + */ + +// Autogenerated +// Do not edit. No need to extend this class. +package org.openecomp.ncomp.sirius.manager.agent.servers.monitoring.south; + + + + + +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.ncomp.sirius.manager.server.impl.SouthBoundApiImpl; +import org.openecomp.ncomp.sirius.manager.server.SouthBoundApi; + + +public class AgentSouthBoundApiProvider extends BasicAdaptorProvider { + private static final Logger logger = Logger.getLogger(AgentSouthBoundApiProvider.class); + SouthBoundApi o; + + public AgentSouthBoundApiProvider(ISiriusServer controller, SouthBoundApi o) { + super(controller, o); + this.o = o; + } + + public void logs(org.json.JSONObject cx, EList<org.openecomp.ncomp.core.logs.LogMessage> logs) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); +// + } + + public void metrics(org.json.JSONObject cx, EList<org.openecomp.ncomp.core.metrics.Metric> metrics) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); +// + } + + public void properties(org.json.JSONObject cx, EList<org.openecomp.ncomp.sirius.manager.properties.AbstractProperty> l) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); +// + } + + + + + + public static void ecoreSetup() { + // TODO Auto-generated method stub + + } + + +} diff --git a/ncomp-sirius-manager-agent-server/src/main/server-gen/bin/sirius-manager-agent-server-controller b/ncomp-sirius-manager-agent-server/src/main/server-gen/bin/sirius-manager-agent-server-controller new file mode 100644 index 0000000..86a0713 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/server-gen/bin/sirius-manager-agent-server-controller @@ -0,0 +1,137 @@ +#!/bin/bash + +# setup env if needed. java 6 required +## JAVA_HOME= + +############################## DO NOT EDIT BELOW ########################## + +SNAME="Agent Controller" +PNAME=sirius-manager-agent-server-controller +CLASS=org.openecomp.ncomp.sirius.manager.agent.servers.monitoring.AgentSiriusManagerAgentServerServer + +############################## 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 +case $CMD in + status) + echo $_STATUS + exit 0 + ;; + console) + CP=$(find $_DIR/lib -name \*.jar | xargs -I X printf ":%s" X) + $GROOVY_HOME/bin/groovysh -cp $_DIR/config:$_DIR/lib:$CP + ;; + run) + CP=$(find $_DIR/lib -name \*.jar | xargs -I X printf ":%s" X) + $JAVA_HOME/bin/java -cp $_DIR/config:$_DIR/lib:$CP "$@" + ;; + groovy) + CP=$(find $_DIR/lib -name \*.jar | xargs -I X printf ":%s" X) + $GROOVY_HOME/bin/groovy -cp $_DIR/config:$_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 + CP=$(find $_DIR/lib -name \*.jar | xargs -I X printf ":%s" X) + + nohup $JAVA_HOME/bin/java -cp $_DIR/config:$_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/ncomp-sirius-manager-agent-server/src/main/server/bin/agent.sh b/ncomp-sirius-manager-agent-server/src/main/server/bin/agent.sh new file mode 100644 index 0000000..f674aef --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/server/bin/agent.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +export JAVA_HOME=/opt/app/java/jdk/jdk170 +export GROOVY_HOME=/opt/app/groovy/246 + +PATH=$JAVA_HOME/bin:$GROOVY_HOME/bin:$PATH + +cd $(dirname $(dirname $(readlink -e $0))) + +ROOT=$(pwd) +CMD=$ROOT/bin/sirius-manager-agent-server-controller + + +mkdir -p logs/ +echo $(date) bin/agent.sh "$@" >> logs/agent.sh.log + +CMD1=$1 +VMTYPE=monitoring-agent + +case $CMD1 in + start) + JVMARGS=$(cat config/monitoring.properties | grep JVMARGS | sed 's/[^=]*=//') + $CMD $CMD1 $JVMARGS + ;; + stop|console) + $CMD $CMD1 + ;; + config) + CONFIGDIR=/var/config/DCAE/chef + if [ ! -e $CONFIGDIR/$VMTYPE-monitoring.properties ]; then CONFIGDIR=/tmp; fi + mkdir -p config + for FILE in $CONFIGDIR/$VMTYPE-*; do + FILE2=$(echo $FILE | sed s/.*$VMTYPE-//) + cp $FILE config/$FILE2 + done + /opt/app/dcae-controller-core-utils/bin/setup_https.sh config/monitoring.properties + ;; + restore|clean) + ;; + restart) + $0 stop + $0 start + ;; + restart2) + $CMD stop + JVMARGS=$(cat config/monitoring.properties | grep JVMARGS | sed 's/[^=]*=//') + $CMD start $JVMARGS + ;; + *) + echo unknown command: $CMD1 + ;; +esac + +exit 0 + diff --git a/ncomp-sirius-manager-agent-server/src/main/server/config/console.properties b/ncomp-sirius-manager-agent-server/src/main/server/config/console.properties new file mode 100644 index 0000000..4b63607 --- /dev/null +++ b/ncomp-sirius-manager-agent-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/ncomp-sirius-manager-agent-server/src/main/server/config/gui.properties b/ncomp-sirius-manager-agent-server/src/main/server/config/gui.properties new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/server/config/gui.properties diff --git a/ncomp-sirius-manager-agent-server/src/main/server/config/makefile b/ncomp-sirius-manager-agent-server/src/main/server/config/makefile new file mode 100644 index 0000000..717823e --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/server/config/makefile @@ -0,0 +1,9 @@ + +restart: stop start + +start: + M2_HOME=/home/ncomp/.m2 bin/BBBB-controller start +stop: + bin/BBBB-controller stop +console: + bin/BBBB-controller console diff --git a/ncomp-sirius-manager-agent-server/src/main/server/config/pw.sh.sh b/ncomp-sirius-manager-agent-server/src/main/server/config/pw.sh.sh new file mode 100644 index 0000000..cd022ae --- /dev/null +++ b/ncomp-sirius-manager-agent-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 +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/ncomp-sirius-manager-agent-server/src/main/server/config/server.properties b/ncomp-sirius-manager-agent-server/src/main/server/config/server.properties new file mode 100644 index 0000000..4605389 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/server/config/server.properties @@ -0,0 +1,7 @@ +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 diff --git a/ncomp-sirius-manager-agent-server/src/main/server/scripts/console.groovy b/ncomp-sirius-manager-agent-server/src/main/server/scripts/console.groovy new file mode 100644 index 0000000..5c94104 --- /dev/null +++ b/ncomp-sirius-manager-agent-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.ncomp.sirius.manager.agent.servers.monitoring.AgentSiriusManagerAgentServerConsole +import org.openecomp.ncomp.sirius.manager.console.Utils + +server = new AgentSiriusManagerAgentServerConsole("console.properties","localhost") + +def p(x) { Utils.object2json(x).toString(2) } diff --git a/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentMonitoringFactory.java b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentMonitoringFactory.java new file mode 100644 index 0000000..39ef288 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentMonitoringFactory.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.ncomp.sirius.manager.agent.servers.monitoring; + +import org.eclipse.emf.ecore.EPackage; +import org.apache.log4j.Logger; + +import org.openecomp.ncomp.sirius.manager.ISiriusServer; + +import org.openecomp.ncomp.sirius.manager.agent.monitoring.SiriusManagerAgentServer; +import org.openecomp.ncomp.sirius.manager.agent.monitoring.MonitoringPackage; +import org.openecomp.ncomp.sirius.manager.agent.monitoring.impl.MonitoringFactoryImpl; + + + + + +public class AgentMonitoringFactory extends MonitoringFactoryImpl { + public static final Logger logger = Logger.getLogger(AgentMonitoringFactory.class); + ISiriusServer server = null; + @Override + public EPackage getEPackage() { return MonitoringPackage.eINSTANCE; } + public AgentMonitoringFactory(ISiriusServer server) { + this.server = server; + } + @Override + public SiriusManagerAgentServer createSiriusManagerAgentServer() { + return new AgentSiriusManagerAgentServer(server); + } + + + +} diff --git a/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentSiriusManagerAgentServer.java b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentSiriusManagerAgentServer.java new file mode 100644 index 0000000..f4147a4 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentSiriusManagerAgentServer.java @@ -0,0 +1,301 @@ + +/*- + * ============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.ncomp.sirius.manager.agent.servers.monitoring; + +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.openecomp.ncomp.component.ApiRequestStatus; + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; +import org.json.JSONObject; +import java.util.Date; + + + + +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.agent.monitoring.impl.SiriusManagerAgentServerImpl; + + + +public class AgentSiriusManagerAgentServer extends SiriusManagerAgentServerImpl implements ISiriusPlugin { + public static final Logger logger = Logger.getLogger(AgentSiriusManagerAgentServer.class); + AgentSiriusManagerAgentServerProvider controller; + ISiriusServer server; + + public AgentSiriusManagerAgentServer(ISiriusServer server) { + this.server = server; + this.controller = new AgentSiriusManagerAgentServerProvider(server,this); + } + + 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(); + 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); + throw e; + } + 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(); + 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); + throw e; + } + 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(); + 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); + throw e; + } + 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(); + 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); + throw e; + } + 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(); + 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); + throw e; + } + 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(); + 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); + throw e; + } + 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(); + 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); + throw e; + } + 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(); + 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); + throw e; + } + 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(); + 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); + throw e; + } + 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(); + 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); + throw e; + } + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "update", ApiRequestStatus.OKAY, duration_,path,function); + + } + + + + + + + @Override + public void start() { + controller.start(); + } + + + public static void ecoreSetup() { + AgentSiriusManagerAgentServerProvider.ecoreSetup(); + } + +} diff --git a/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentSiriusManagerAgentServerClient.java b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentSiriusManagerAgentServerClient.java new file mode 100644 index 0000000..db52905 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentSiriusManagerAgentServerClient.java @@ -0,0 +1,119 @@ + +/*- + * ============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.ncomp.sirius.manager.agent.servers.monitoring; + +import org.openecomp.ncomp.sirius.manager.AbstractClient; +import org.openecomp.ncomp.sirius.manager.HighAvailabilityClient; +import org.openecomp.ncomp.sirius.manager.Jetty8Client; + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.openecomp.ncomp.sirius.manager.agent.monitoring.impl.SiriusManagerAgentServerImpl; +import org.openecomp.ncomp.sirius.manager.agent.monitoring.MonitoringPackage; + + + + + + +@SuppressWarnings("unchecked") +public class AgentSiriusManagerAgentServerClient extends SiriusManagerAgentServerImpl { + public static final Logger logger = Logger.getLogger(AgentSiriusManagerAgentServerClient.class); + public AbstractClient client; + + public AgentSiriusManagerAgentServerClient(String file, String name) { + AgentSiriusManagerAgentServer.ecoreSetup(); + client = new Jetty8Client(file,name); + client.add("/resources", this); + } + + public AgentSiriusManagerAgentServerClient(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); + } + + + @Override + public void logs(org.json.JSONObject cx, EList<org.openecomp.ncomp.core.logs.LogMessage> logs) { + EClass c = MonitoringPackage.eINSTANCE.getSiriusManagerAgentServer(); + client.operationPath("/resources", c, "logs", cx != null && cx.has("timeout") ? cx.getLong("timeout") : null, cx,logs); + } + + @Override + public void metrics(org.json.JSONObject cx, EList<org.openecomp.ncomp.core.metrics.Metric> metrics) { + EClass c = MonitoringPackage.eINSTANCE.getSiriusManagerAgentServer(); + client.operationPath("/resources", c, "metrics", cx != null && cx.has("timeout") ? cx.getLong("timeout") : null, cx,metrics); + } + + @Override + public void properties(org.json.JSONObject cx, EList<org.openecomp.ncomp.sirius.manager.properties.AbstractProperty> l) { + EClass c = MonitoringPackage.eINSTANCE.getSiriusManagerAgentServer(); + client.operationPath("/resources", c, "properties", cx != null && cx.has("timeout") ? cx.getLong("timeout") : null, cx,l); + } + + @Override + public void uploadInfo(org.json.JSONObject cx, EList<org.openecomp.ncomp.sirius.manager.server.ManagementInfo> info) { + EClass c = MonitoringPackage.eINSTANCE.getSiriusManagerAgentServer(); + client.operationPath("/resources", c, "uploadInfo", cx != null && cx.has("timeout") ? cx.getLong("timeout") : null, cx,info); + } + + @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 = MonitoringPackage.eINSTANCE.getSiriusManagerAgentServer(); + return (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); + } + + @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 = MonitoringPackage.eINSTANCE.getSiriusManagerAgentServer(); + return (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); + } + + @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 = MonitoringPackage.eINSTANCE.getSiriusManagerAgentServer(); + return (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); + } + + @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 = MonitoringPackage.eINSTANCE.getSiriusManagerAgentServer(); + return (org.openecomp.ncomp.sirius.manager.server.LoggerInfo) client.operationPath("/resources", c, "getRequestLogger", null, userName,action,resourcePath,context); + } + + @Override + public EList<org.openecomp.ncomp.core.function.ValuePair> evaluate(java.lang.String path, org.openecomp.ncomp.core.function.Function function) { + EClass c = MonitoringPackage.eINSTANCE.getSiriusManagerAgentServer(); + return (EList<org.openecomp.ncomp.core.function.ValuePair>) client.operationPath("/resources", c, "evaluate", null, path,function); + } + + @Override + public void update(java.lang.String path, org.openecomp.ncomp.core.function.Function function) { + EClass c = MonitoringPackage.eINSTANCE.getSiriusManagerAgentServer(); + client.operationPath("/resources", c, "update", null, path,function); + } + +} diff --git a/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentSiriusManagerAgentServerConsole.java b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentSiriusManagerAgentServerConsole.java new file mode 100644 index 0000000..4efd29f --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentSiriusManagerAgentServerConsole.java @@ -0,0 +1,164 @@ + +/*- + * ============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.ncomp.sirius.manager.agent.servers.monitoring; + +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.ManagementServerError; + + +import org.openecomp.ncomp.sirius.manager.agent.servers.monitoring.gui.AgentGuiClientApiConsole; +import org.openecomp.ncomp.sirius.manager.agent.servers.monitoring.south.AgentSouthBoundApiConsole; + + +public class AgentSiriusManagerAgentServerConsole extends Console { + public static final Logger logger = Logger.getLogger(AgentSiriusManagerAgentServerConsole.class); + protected AgentSiriusManagerAgentServerClient controller; + + + AgentGuiClientApiConsole gui; + AgentSouthBoundApiConsole south; + + + public AgentSiriusManagerAgentServerConsole(String filename, String name) { + super(filename, name); + controller = new AgentSiriusManagerAgentServerClient(filename,name); + client = controller.client; + + gui = new AgentGuiClientApiConsole(filename,name); + south = new AgentSouthBoundApiConsole(filename,name); + } + + 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/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentSiriusManagerAgentServerProviderTemplate.java b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentSiriusManagerAgentServerProviderTemplate.java new file mode 100644 index 0000000..82f9dc6 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentSiriusManagerAgentServerProviderTemplate.java @@ -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============================================ + */ + +// Autogenerated +// Do not edit. No need to extend this class. +package org.openecomp.ncomp.sirius.manager.agent.servers.monitoring; + + + + + +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.ncomp.sirius.manager.agent.monitoring.impl.SiriusManagerAgentServerImpl; +import org.openecomp.ncomp.sirius.manager.agent.monitoring.SiriusManagerAgentServer; + + +public class AgentSiriusManagerAgentServerProviderTemplate extends BasicManagementServerProvider { + private static final Logger logger = Logger.getLogger(AgentSiriusManagerAgentServerProviderTemplate.class); + SiriusManagerAgentServer o; + + public AgentSiriusManagerAgentServerProviderTemplate(ISiriusServer controller, SiriusManagerAgentServer o) { + super(controller, o); + this.o = o; + } + + + + + + public void start() { + + // TODO Auto-generated method stub + } + + public static void ecoreSetup() { + // TODO Auto-generated method stub + + } + + +} diff --git a/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentSiriusManagerAgentServerServer.java b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentSiriusManagerAgentServerServer.java new file mode 100644 index 0000000..a98eabe --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/AgentSiriusManagerAgentServerServer.java @@ -0,0 +1,116 @@ + +/*- + * ============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.ncomp.sirius.manager.agent.servers.monitoring; + +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.ncomp.sirius.manager.Jetty8Server; +import org.openecomp.ncomp.sirius.manager.ManagementServer; +import org.openecomp.ncomp.sirius.manager.ISiriusServer; + +import org.openecomp.ncomp.sirius.manager.agent.monitoring.SiriusManagerAgentServer; + + +import org.openecomp.ncomp.sirius.manager.agent.servers.monitoring.gui.AgentModelFactory; + +import org.openecomp.ncomp.sirius.manager.agent.servers.monitoring.south.AgentServerFactory; + + + + + +public class AgentSiriusManagerAgentServerServer implements ISiriusServer { + public static final Logger logger = Logger.getLogger(AgentSiriusManagerAgentServerServer.class); + String serverPath; + ManagementServer server; + AgentSiriusManagerAgentServer controller; + String directory = "data"; +// LocationControllerApi api ; + Jetty8Server webServer; + AgentMonitoringFactory f = new AgentMonitoringFactory(this); + + String guiPath; + ManagementServer guiServer; + + String southPath; + ManagementServer southServer; + + + public AgentSiriusManagerAgentServerServer(String filename) throws IOException { + logger.warn("controller restarting"); + AgentSiriusManagerAgentServer.ecoreSetup(); + props = getPropertiesFromClasspath(filename); + serverPath = (String) props.get("server.dir"); + server = new ManagementServer(f, "SiriusManagerAgentServer", serverPath, filename); + server.addFactory(f); + + server.addRuntimeFactories(this); + server.start(); + } + public void runWebserver() throws IOException { + controller = (AgentSiriusManagerAgentServer) server.find("/").o; + webServer = new Jetty8Server("monitoring.properties"); + webServer.add("/resources",server); + + + + EFactory guiFactory = new AgentModelFactory(this); + guiPath = serverPath + "/gui"; + guiServer = new ManagementServer(guiFactory, "GuiClientApi", guiPath, "gui.properties"); + guiServer.start(); + webServer.add("/gui",guiServer); + + EFactory southFactory = new AgentServerFactory(this); + southPath = serverPath + "/south"; + southServer = new ManagementServer(southFactory, "SouthBoundApi", southPath, "south.properties"); + southServer.start(); + webServer.add("/south",southServer); + + + + 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")); + + AgentSiriusManagerAgentServerServer s = new AgentSiriusManagerAgentServerServer("monitoring.properties"); + s.runWebserver(); + } + public SiriusManagerAgentServer getController() { + return controller; + } + public ManagementServer getServer() { + return server; + } +} diff --git a/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/gui/AgentGuiClientApi.java b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/gui/AgentGuiClientApi.java new file mode 100644 index 0000000..37332ad --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/gui/AgentGuiClientApi.java @@ -0,0 +1,215 @@ + +/*- + * ============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.ncomp.sirius.manager.agent.servers.monitoring.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.openecomp.ncomp.component.ApiRequestStatus; + +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.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 AgentGuiClientApi extends GuiClientApiImpl { + public static final Logger logger = Logger.getLogger(AgentGuiClientApi.class); + AgentGuiClientApiProvider controller; + ISiriusServer server; + + public AgentGuiClientApi(ISiriusServer server) { + this.server = server; + this.controller = new AgentGuiClientApiProvider(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(); + 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); + throw e; + } + 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(); + 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); + throw e; + } + 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(); + 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); + throw e; + } + 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(); + 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); + throw e; + } + 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(); + 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); + throw e; + } + 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(); + 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); + throw e; + } + 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() { + AgentGuiClientApiProvider.ecoreSetup(); + } + +} diff --git a/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/gui/AgentGuiClientApiClient.java b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/gui/AgentGuiClientApiClient.java new file mode 100644 index 0000000..f480a06 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/gui/AgentGuiClientApiClient.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============================================ + */ + +// Autogenerated +// Do not edit. No need to extend this class. +package org.openecomp.ncomp.sirius.manager.agent.servers.monitoring.gui; + +import org.openecomp.ncomp.sirius.manager.AbstractClient; +import org.openecomp.ncomp.sirius.manager.HighAvailabilityClient; +import org.openecomp.ncomp.sirius.manager.Jetty8Client; + +import org.apache.log4j.Logger; +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.ncomp.sirius.manager.agent.servers.monitoring.AgentSiriusManagerAgentServer; + + + + +@SuppressWarnings("unchecked") +public class AgentGuiClientApiClient extends GuiClientApiImpl { + public static final Logger logger = Logger.getLogger(AgentGuiClientApiClient.class); + public AbstractClient client; + + public AgentGuiClientApiClient(String file, String name) { + AgentSiriusManagerAgentServer.ecoreSetup(); + client = new Jetty8Client(file,name); + client.add("/gui", this); + } + + public AgentGuiClientApiClient(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); + } + + + @Override + public org.openecomp.ncomp.gwt.siriusportal.model.GuiTree getTree() { + EClass c = ModelPackage.eINSTANCE.getGuiClientApi(); + return (org.openecomp.ncomp.gwt.siriusportal.model.GuiTree) client.operationPath("/gui", c, "getTree", null); + } + + @Override + public org.openecomp.ncomp.gwt.siriusportal.model.GuiObject getObject(java.lang.String path) { + EClass c = ModelPackage.eINSTANCE.getGuiClientApi(); + return (org.openecomp.ncomp.gwt.siriusportal.model.GuiObject) client.operationPath("/gui", c, "getObject", null, path); + } + + @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(); + return (org.openecomp.ncomp.gwt.siriusportal.model.GuiTimeSerie) client.operationPath("/gui", c, "getTimeSerie", null, path,start,end,duration); + } + + @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(); + return (org.openecomp.ncomp.gwt.siriusportal.model.GuiTable) client.operationPath("/gui", c, "getTable", null, path,start,end); + } + + @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(); + return (org.openecomp.ncomp.gwt.siriusportal.model.GuiHtml) client.operationPath("/gui", c, "getHtml", null, path,start,end); + } + + @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(); + return (org.openecomp.ncomp.sirius.manager.graph.GuiGraph) client.operationPath("/gui", c, "getGraph", null, path,start,end); + } + +} diff --git a/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/gui/AgentGuiClientApiConsole.java b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/gui/AgentGuiClientApiConsole.java new file mode 100644 index 0000000..2a18f02 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/gui/AgentGuiClientApiConsole.java @@ -0,0 +1,114 @@ + +/*- + * ============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.ncomp.sirius.manager.agent.servers.monitoring.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.ManagementServerError; + + + + +public class AgentGuiClientApiConsole extends Console { + public static final Logger logger = Logger.getLogger(AgentGuiClientApiConsole.class); + protected AgentGuiClientApiClient controller; + + + + + public AgentGuiClientApiConsole(String filename, String name) { + super(filename, name); + controller = new AgentGuiClientApiClient(filename,name); + 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/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/gui/AgentGuiClientApiProviderTemplate.java b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/gui/AgentGuiClientApiProviderTemplate.java new file mode 100644 index 0000000..43754f4 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/gui/AgentGuiClientApiProviderTemplate.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.ncomp.sirius.manager.agent.servers.monitoring.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 AgentGuiClientApiProviderTemplate extends BasicGuiClientApiProvider { + private static final Logger logger = Logger.getLogger(AgentGuiClientApiProviderTemplate.class); + GuiClientApi o; + + public AgentGuiClientApiProviderTemplate(ISiriusServer controller, GuiClientApi o) { + super(controller, o); + this.o = o; + } + + + + + + public static void ecoreSetup() { + // TODO Auto-generated method stub + + } + + +} diff --git a/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/gui/AgentModelFactory.java b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/gui/AgentModelFactory.java new file mode 100644 index 0000000..cbc41f6 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/gui/AgentModelFactory.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.ncomp.sirius.manager.agent.servers.monitoring.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.ncomp.sirius.manager.agent.servers.monitoring.AgentSiriusManagerAgentServerServer; + + + +public class AgentModelFactory extends ModelFactoryImpl { + public static final Logger logger = Logger.getLogger(AgentModelFactory.class); + ISiriusServer server = null; + @Override + public EPackage getEPackage() { return ModelPackage.eINSTANCE; } + public AgentModelFactory(ISiriusServer server) { + this.server = server; + } + @Override + public GuiClientApi createGuiClientApi() { + return new AgentGuiClientApi(server); + } + + + +} diff --git a/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/south/AgentServerFactory.java b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/south/AgentServerFactory.java new file mode 100644 index 0000000..f80a2ae --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/south/AgentServerFactory.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.ncomp.sirius.manager.agent.servers.monitoring.south; + +import org.eclipse.emf.ecore.EPackage; +import org.apache.log4j.Logger; + +import org.openecomp.ncomp.sirius.manager.ISiriusServer; + +import org.openecomp.ncomp.sirius.manager.server.SouthBoundApi; +import org.openecomp.ncomp.sirius.manager.server.ServerPackage; +import org.openecomp.ncomp.sirius.manager.server.impl.ServerFactoryImpl; + +import org.openecomp.ncomp.sirius.manager.agent.servers.monitoring.AgentSiriusManagerAgentServerServer; + + + +public class AgentServerFactory extends ServerFactoryImpl { + public static final Logger logger = Logger.getLogger(AgentServerFactory.class); + ISiriusServer server = null; + @Override + public EPackage getEPackage() { return ServerPackage.eINSTANCE; } + public AgentServerFactory(ISiriusServer server) { + this.server = server; + } + @Override + public SouthBoundApi createSouthBoundApi() { + return new AgentSouthBoundApi(server); + } + + + +} diff --git a/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/south/AgentSouthBoundApi.java b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/south/AgentSouthBoundApi.java new file mode 100644 index 0000000..9f3fe78 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/south/AgentSouthBoundApi.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. No need to extend this class. +package org.openecomp.ncomp.sirius.manager.agent.servers.monitoring.south; + +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.openecomp.ncomp.component.ApiRequestStatus; + +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.impl.SouthBoundApiImpl; + + + +public class AgentSouthBoundApi extends SouthBoundApiImpl { + public static final Logger logger = Logger.getLogger(AgentSouthBoundApi.class); + AgentSouthBoundApiProvider controller; + ISiriusServer server; + + public AgentSouthBoundApi(ISiriusServer server) { + this.server = server; + this.controller = new AgentSouthBoundApiProvider(server,this); + } + + 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(); + 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); + throw e; + } + 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(); + 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); + throw e; + } + 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(); + 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); + throw e; + } + duration_ = new Date().getTime()-now_.getTime(); + if (server != null) + server.getServer().recordApi(null, this, "properties", ApiRequestStatus.OKAY, duration_,cx,l); + + } + + + + + + + public static void ecoreSetup() { + AgentSouthBoundApiProvider.ecoreSetup(); + } + +} diff --git a/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/south/AgentSouthBoundApiClient.java b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/south/AgentSouthBoundApiClient.java new file mode 100644 index 0000000..223f47d --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/south/AgentSouthBoundApiClient.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============================================ + */ + +// Autogenerated +// Do not edit. No need to extend this class. +package org.openecomp.ncomp.sirius.manager.agent.servers.monitoring.south; + +import org.openecomp.ncomp.sirius.manager.AbstractClient; +import org.openecomp.ncomp.sirius.manager.HighAvailabilityClient; +import org.openecomp.ncomp.sirius.manager.Jetty8Client; + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.openecomp.ncomp.sirius.manager.server.impl.SouthBoundApiImpl; +import org.openecomp.ncomp.sirius.manager.server.ServerPackage; + + +import org.openecomp.ncomp.sirius.manager.agent.servers.monitoring.AgentSiriusManagerAgentServer; + + + + +@SuppressWarnings("unchecked") +public class AgentSouthBoundApiClient extends SouthBoundApiImpl { + public static final Logger logger = Logger.getLogger(AgentSouthBoundApiClient.class); + public AbstractClient client; + + public AgentSouthBoundApiClient(String file, String name) { + AgentSiriusManagerAgentServer.ecoreSetup(); + client = new Jetty8Client(file,name); + client.add("/south", this); + } + + public AgentSouthBoundApiClient(String file, String name1, String name2) { + HighAvailabilityClient client1 = new HighAvailabilityClient(file,name1,name2); + client = client1.all; // requests should be forwarded to all. + client.add("/south", this); + } + + + @Override + public void logs(org.json.JSONObject cx, EList<org.openecomp.ncomp.core.logs.LogMessage> logs) { + EClass c = ServerPackage.eINSTANCE.getSouthBoundApi(); + client.operationPath("/south", c, "logs", cx != null && cx.has("timeout") ? cx.getLong("timeout") : null, cx,logs); + } + + @Override + public void metrics(org.json.JSONObject cx, EList<org.openecomp.ncomp.core.metrics.Metric> metrics) { + EClass c = ServerPackage.eINSTANCE.getSouthBoundApi(); + client.operationPath("/south", c, "metrics", cx != null && cx.has("timeout") ? cx.getLong("timeout") : null, cx,metrics); + } + + @Override + public void properties(org.json.JSONObject cx, EList<org.openecomp.ncomp.sirius.manager.properties.AbstractProperty> l) { + EClass c = ServerPackage.eINSTANCE.getSouthBoundApi(); + client.operationPath("/south", c, "properties", cx != null && cx.has("timeout") ? cx.getLong("timeout") : null, cx,l); + } + +} diff --git a/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/south/AgentSouthBoundApiConsole.java b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/south/AgentSouthBoundApiConsole.java new file mode 100644 index 0000000..e65be04 --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/south/AgentSouthBoundApiConsole.java @@ -0,0 +1,81 @@ + +/*- + * ============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.ncomp.sirius.manager.agent.servers.monitoring.south; + +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.ManagementServerError; + + + + +public class AgentSouthBoundApiConsole extends Console { + public static final Logger logger = Logger.getLogger(AgentSouthBoundApiConsole.class); + protected AgentSouthBoundApiClient controller; + + + + + public AgentSouthBoundApiConsole(String filename, String name) { + super(filename, name); + controller = new AgentSouthBoundApiClient(filename,name); + client = controller.client; + + } + + 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)); + } + + } + +} diff --git a/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/south/AgentSouthBoundApiProviderTemplate.java b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/south/AgentSouthBoundApiProviderTemplate.java new file mode 100644 index 0000000..fb7d5df --- /dev/null +++ b/ncomp-sirius-manager-agent-server/src/main/sirius-gen/org/openecomp/ncomp/sirius/manager/agent/servers/monitoring/south/AgentSouthBoundApiProviderTemplate.java @@ -0,0 +1,86 @@ + +/*- + * ============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.ncomp.sirius.manager.agent.servers.monitoring.south; + + + + + +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.ncomp.sirius.manager.server.impl.SouthBoundApiImpl; +import org.openecomp.ncomp.sirius.manager.server.SouthBoundApi; + + +public class AgentSouthBoundApiProviderTemplate extends BasicAdaptorProvider { + private static final Logger logger = Logger.getLogger(AgentSouthBoundApiProviderTemplate.class); + SouthBoundApi o; + + public AgentSouthBoundApiProviderTemplate(ISiriusServer controller, SouthBoundApi o) { + super(controller, o); + this.o = o; + } + + public void logs(org.json.JSONObject cx, EList<org.openecomp.ncomp.core.logs.LogMessage> logs) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void metrics(org.json.JSONObject cx, EList<org.openecomp.ncomp.core.metrics.Metric> metrics) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + public void properties(org.json.JSONObject cx, EList<org.openecomp.ncomp.sirius.manager.properties.AbstractProperty> l) { + + // TODO IMPLEMENT + throw new UnsupportedOperationException(); + } + + + + + + public static void ecoreSetup() { + // TODO Auto-generated method stub + + } + + +} |