diff options
author | Venkata Harish K Kajur <vk250x@att.com> | 2018-01-15 01:03:32 -0500 |
---|---|---|
committer | Venkata Harish K Kajur <vk250x@att.com> | 2018-01-15 01:04:18 -0500 |
commit | 086088ae889bd30b39fa2ceede2875717e6da27e (patch) | |
tree | b70510f016f3f49019001d3e8676eac91c210837 /aai-resources | |
parent | 6c70463a3347beaa54e034266019ea3c6733c8f0 (diff) |
Add all of the command line tools
for the get put update and releationship tools
Issue-ID: AAI-488
Issue-ID: AAI-489
Issue-ID: AAI-490
Issue-ID: AAI-491
Issue-ID: AAI-492
Change-Id: Ie38f93e56b062d3d6966b191af5a9bc1817cf40e
Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
Diffstat (limited to 'aai-resources')
-rw-r--r-- | aai-resources/bundleconfig-local/etc/appprops/deltool-logback.xml | 123 | ||||
-rw-r--r-- | aai-resources/bundleconfig-local/etc/appprops/posttool-logback.xml | 123 | ||||
-rw-r--r-- | aai-resources/bundleconfig-local/etc/appprops/prov-logback.xml | 123 | ||||
-rw-r--r-- | aai-resources/bundleconfig-local/etc/appprops/puttool-logback.xml | 123 | ||||
-rw-r--r-- | aai-resources/bundleconfig-local/etc/appprops/rshiptool-logback.xml | 123 | ||||
-rw-r--r-- | aai-resources/bundleconfig-local/etc/appprops/updtool-logback.xml | 123 | ||||
-rw-r--r-- | aai-resources/src/main/scripts/deleteTool.sh | 148 | ||||
-rw-r--r-- | aai-resources/src/main/scripts/getTool.sh | 106 | ||||
-rw-r--r-- | aai-resources/src/main/scripts/putTool.sh | 161 | ||||
-rw-r--r-- | aai-resources/src/main/scripts/rshipTool.sh | 226 | ||||
-rw-r--r-- | aai-resources/src/main/scripts/updateTool.sh | 211 |
11 files changed, 833 insertions, 757 deletions
diff --git a/aai-resources/bundleconfig-local/etc/appprops/deltool-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/deltool-logback.xml deleted file mode 100644 index 5e8a820..0000000 --- a/aai-resources/bundleconfig-local/etc/appprops/deltool-logback.xml +++ /dev/null @@ -1,123 +0,0 @@ -<!-- - - ============LICENSE_START======================================================= - org.onap.aai - ================================================================================ - Copyright © 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 is a trademark and service mark of AT&T Intellectual Property. - ---> -<configuration> - <property name="logDirectory" value="${AJSC_HOME}/logs" /> - <property name="eelfLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - <property name="eelfMetricLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{targetVirtualEntity}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - - <appender name="delTool" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>WARN</level> - </filter> - <File>${logDirectory}/delTool/error.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/delTool/error.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="delTooldebug" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>DEBUG</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/delTool/debug.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/delTool/debug.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="delToolmetric" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/delTool/metrics.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/delTool/metrics.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfMetricLogPattern}</pattern> - </encoder> - </appender> - - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder>%-4relative [%thread] %-5level %logger{35} - %msg %n</encoder> - </appender> - - <logger name="org.reflections" level="WARN" additivity="false"> - <appender-ref ref="delTool"/> - <appender-ref ref="delTooldebug"/> - <appender-ref ref="delToolmetric"/> - </logger> - <logger name="org.apache.zookeeper" level="WARN" additivity="false"> - <appender-ref ref="delTool"/> - <appender-ref ref="delTooldebug"/> - <appender-ref ref="delToolmetric"/> - </logger> - <logger name="org.apache.hadoop" level="WARN" additivity="false"> - <appender-ref ref="delTool"/> - <appender-ref ref="delTooldebug"/> - <appender-ref ref="delToolmetric"/> - </logger> - <logger name="com.thinkaurelius" level="WARN" additivity="false"> - <appender-ref ref="delTool"/> - <appender-ref ref="delTooldebug"/> - <appender-ref ref="delToolmetric"/> - </logger> - <logger name="ch.qos.logback.classic" level="WARN" additivity="false"> - <appender-ref ref="delTool"/> - <appender-ref ref="delTooldebug"/> - <appender-ref ref="delToolmetric"/> - </logger> - <logger name="ch.qos.logback.core" level="WARN" additivity="false"> - <appender-ref ref="delTool"/> - <appender-ref ref="delTooldebug"/> - <appender-ref ref="delToolmetric"/> - </logger> - <logger name="com.att.eelf" level="WARN" additivity="false"> - <appender-ref ref="delTool"/> - <appender-ref ref="delTooldebug"/> - <appender-ref ref="delToolmetric"/> - </logger> - <logger name="org.onap.aai" level="INFO" additivity="false"> - <appender-ref ref="delTool"/> - <appender-ref ref="delTooldebug"/> - <appender-ref ref="delToolmetric"/> - </logger> - - <root level="INFO"> - <appender-ref ref="delTool"/> - <appender-ref ref="delTooldebug"/> - <appender-ref ref="delToolmetric"/> - <appender-ref ref="STDOUT"/> - </root> -</configuration> diff --git a/aai-resources/bundleconfig-local/etc/appprops/posttool-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/posttool-logback.xml deleted file mode 100644 index 01b3d84..0000000 --- a/aai-resources/bundleconfig-local/etc/appprops/posttool-logback.xml +++ /dev/null @@ -1,123 +0,0 @@ -<!-- - - ============LICENSE_START======================================================= - org.onap.aai - ================================================================================ - Copyright © 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 is a trademark and service mark of AT&T Intellectual Property. - ---> -<configuration> - <property name="logDirectory" value="${AJSC_HOME}/logs" /> - <property name="eelfLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - <property name="eelfMetricLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{targetVirtualEntity}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - - <appender name="postTool" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>WARN</level> - </filter> - <File>${logDirectory}/postTool/error.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/postTool/error.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="postTooldebug" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>DEBUG</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/postTool/debug.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/postTool/debug.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="postToolmetric" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/postTool/metrics.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/postTool/metrics.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfMetricLogPattern}</pattern> - </encoder> - </appender> - - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder>%-4relative [%thread] %-5level %logger{35} - %msg %n</encoder> - </appender> - - <logger name="org.reflections" level="WARN" additivity="false"> - <appender-ref ref="postTool"/> - <appender-ref ref="postTooldebug"/> - <appender-ref ref="postToolmetric"/> - </logger> - <logger name="org.apache.zookeeper" level="WARN" additivity="false"> - <appender-ref ref="postTool"/> - <appender-ref ref="postTooldebug"/> - <appender-ref ref="postToolmetric"/> - </logger> - <logger name="org.apache.hadoop" level="WARN" additivity="false"> - <appender-ref ref="postTool"/> - <appender-ref ref="postTooldebug"/> - <appender-ref ref="postToolmetric"/> - </logger> - <logger name="com.thinkaurelius" level="WARN" additivity="false"> - <appender-ref ref="postTool"/> - <appender-ref ref="postTooldebug"/> - <appender-ref ref="postToolmetric"/> - </logger> - <logger name="ch.qos.logback.classic" level="WARN" additivity="false"> - <appender-ref ref="postTool"/> - <appender-ref ref="postTooldebug"/> - <appender-ref ref="postToolmetric"/> - </logger> - <logger name="ch.qos.logback.core" level="WARN" additivity="false"> - <appender-ref ref="postTool"/> - <appender-ref ref="postTooldebug"/> - <appender-ref ref="postToolmetric"/> - </logger> - <logger name="com.att.eelf" level="WARN" additivity="false"> - <appender-ref ref="postTool"/> - <appender-ref ref="postTooldebug"/> - <appender-ref ref="postToolmetric"/> - </logger> - <logger name="org.onap.aai" level="INFO" additivity="false"> - <appender-ref ref="postTool"/> - <appender-ref ref="postTooldebug"/> - <appender-ref ref="postToolmetric"/> - </logger> - - <root level="INFO"> - <appender-ref ref="postTool"/> - <appender-ref ref="postTooldebug"/> - <appender-ref ref="postToolmetric"/> - <appender-ref ref="STDOUT"/> - </root> -</configuration> diff --git a/aai-resources/bundleconfig-local/etc/appprops/prov-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/prov-logback.xml deleted file mode 100644 index 552ff0c..0000000 --- a/aai-resources/bundleconfig-local/etc/appprops/prov-logback.xml +++ /dev/null @@ -1,123 +0,0 @@ -<!-- - - ============LICENSE_START======================================================= - org.onap.aai - ================================================================================ - Copyright © 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 is a trademark and service mark of AT&T Intellectual Property. - ---> -<configuration> - <property name="logDirectory" value="${AJSC_HOME}/logs" /> - <property name="eelfLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - <property name="eelfMetricLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{targetVirtualEntity}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - - <appender name="provTool" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>WARN</level> - </filter> - <File>${logDirectory}/provTool/error.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/provTool/error.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="provTooldebug" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>DEBUG</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/provTool/debug.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/provTool/debug.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="provToolmetric" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/provTool/metrics.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/provTool/metrics.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfMetricLogPattern}</pattern> - </encoder> - </appender> - - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder>%-4relative [%thread] %-5level %logger{35} - %msg %n</encoder> - </appender> - - <logger name="org.reflections" level="WARN" additivity="false"> - <appender-ref ref="provTool"/> - <appender-ref ref="provTooldebug"/> - <appender-ref ref="provToolmetric"/> - </logger> - <logger name="org.apache.zookeeper" level="WARN" additivity="false"> - <appender-ref ref="provTool"/> - <appender-ref ref="provTooldebug"/> - <appender-ref ref="provToolmetric"/> - </logger> - <logger name="org.apache.hadoop" level="WARN" additivity="false"> - <appender-ref ref="provTool"/> - <appender-ref ref="provTooldebug"/> - <appender-ref ref="provToolmetric"/> - </logger> - <logger name="com.thinkaurelius" level="WARN" additivity="false"> - <appender-ref ref="provTool"/> - <appender-ref ref="provTooldebug"/> - <appender-ref ref="provToolmetric"/> - </logger> - <logger name="ch.qos.logback.classic" level="WARN" additivity="false"> - <appender-ref ref="provTool"/> - <appender-ref ref="provTooldebug"/> - <appender-ref ref="provToolmetric"/> - </logger> - <logger name="ch.qos.logback.core" level="WARN" additivity="false"> - <appender-ref ref="provTool"/> - <appender-ref ref="provTooldebug"/> - <appender-ref ref="provToolmetric"/> - </logger> - <logger name="com.att.eelf" level="WARN" additivity="false"> - <appender-ref ref="provTool"/> - <appender-ref ref="provTooldebug"/> - <appender-ref ref="provToolmetric"/> - </logger> - <logger name="org.onap.aai" level="INFO" additivity="false"> - <appender-ref ref="provTool"/> - <appender-ref ref="provTooldebug"/> - <appender-ref ref="provToolmetric"/> - </logger> - - <root level="INFO"> - <appender-ref ref="provTool"/> - <appender-ref ref="provTooldebug"/> - <appender-ref ref="provToolmetric"/> - <appender-ref ref="STDOUT"/> - </root> -</configuration> diff --git a/aai-resources/bundleconfig-local/etc/appprops/puttool-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/puttool-logback.xml deleted file mode 100644 index c3accfb..0000000 --- a/aai-resources/bundleconfig-local/etc/appprops/puttool-logback.xml +++ /dev/null @@ -1,123 +0,0 @@ -<!-- - - ============LICENSE_START======================================================= - org.onap.aai - ================================================================================ - Copyright © 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 is a trademark and service mark of AT&T Intellectual Property. - ---> -<configuration> - <property name="logDirectory" value="${AJSC_HOME}/logs" /> - <property name="eelfLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - <property name="eelfMetricLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{targetVirtualEntity}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - - <appender name="putTool" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>WARN</level> - </filter> - <File>${logDirectory}/putTool/error.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/putTool/error.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="putTooldebug" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>DEBUG</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/putTool/debug.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/putTool/debug.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="putToolmetric" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/putTool/metrics.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/putTool/metrics.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfMetricLogPattern}</pattern> - </encoder> - </appender> - - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder>%-4relative [%thread] %-5level %logger{35} - %msg %n</encoder> - </appender> - - <logger name="org.reflections" level="WARN" additivity="false"> - <appender-ref ref="putTool"/> - <appender-ref ref="putTooldebug"/> - <appender-ref ref="putToolmetric"/> - </logger> - <logger name="org.apache.zookeeper" level="WARN" additivity="false"> - <appender-ref ref="putTool"/> - <appender-ref ref="putTooldebug"/> - <appender-ref ref="putToolmetric"/> - </logger> - <logger name="org.apache.hadoop" level="WARN" additivity="false"> - <appender-ref ref="putTool"/> - <appender-ref ref="putTooldebug"/> - <appender-ref ref="putToolmetric"/> - </logger> - <logger name="com.thinkaurelius" level="WARN" additivity="false"> - <appender-ref ref="putTool"/> - <appender-ref ref="putTooldebug"/> - <appender-ref ref="putToolmetric"/> - </logger> - <logger name="ch.qos.logback.classic" level="WARN" additivity="false"> - <appender-ref ref="putTool"/> - <appender-ref ref="putTooldebug"/> - <appender-ref ref="putToolmetric"/> - </logger> - <logger name="ch.qos.logback.core" level="WARN" additivity="false"> - <appender-ref ref="putTool"/> - <appender-ref ref="putTooldebug"/> - <appender-ref ref="putToolmetric"/> - </logger> - <logger name="com.att.eelf" level="WARN" additivity="false"> - <appender-ref ref="putTool"/> - <appender-ref ref="putTooldebug"/> - <appender-ref ref="putToolmetric"/> - </logger> - <logger name="org.onap.aai" level="INFO" additivity="false"> - <appender-ref ref="putTool"/> - <appender-ref ref="putTooldebug"/> - <appender-ref ref="putToolmetric"/> - </logger> - - <root level="INFO"> - <appender-ref ref="putTool"/> - <appender-ref ref="putTooldebug"/> - <appender-ref ref="putToolmetric"/> - <appender-ref ref="STDOUT"/> - </root> -</configuration> diff --git a/aai-resources/bundleconfig-local/etc/appprops/rshiptool-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/rshiptool-logback.xml deleted file mode 100644 index 1a86039..0000000 --- a/aai-resources/bundleconfig-local/etc/appprops/rshiptool-logback.xml +++ /dev/null @@ -1,123 +0,0 @@ -<!-- - - ============LICENSE_START======================================================= - org.onap.aai - ================================================================================ - Copyright © 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 is a trademark and service mark of AT&T Intellectual Property. - ---> -<configuration> - <property name="logDirectory" value="${AJSC_HOME}/logs" /> - <property name="eelfLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - <property name="eelfMetricLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{targetVirtualEntity}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - - <appender name="rshipTool" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>WARN</level> - </filter> - <File>${logDirectory}/rshipTool/error.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/rshipTool/error.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="rshipTooldebug" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>DEBUG</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/rshipTool/debug.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/rshipTool/debug.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="rshipToolmetric" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/rshipTool/metrics.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/rshipTool/metrics.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfMetricLogPattern}</pattern> - </encoder> - </appender> - - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder>%-4relative [%thread] %-5level %logger{35} - %msg %n</encoder> - </appender> - - <logger name="org.reflections" level="WARN" additivity="false"> - <appender-ref ref="rshipTool"/> - <appender-ref ref="rshipTooldebug"/> - <appender-ref ref="rshipToolmetric"/> - </logger> - <logger name="org.apache.zookeeper" level="WARN" additivity="false"> - <appender-ref ref="rshipTool"/> - <appender-ref ref="rshipTooldebug"/> - <appender-ref ref="rshipToolmetric"/> - </logger> - <logger name="org.apache.hadoop" level="WARN" additivity="false"> - <appender-ref ref="rshipTool"/> - <appender-ref ref="rshipTooldebug"/> - <appender-ref ref="rshipToolmetric"/> - </logger> - <logger name="com.thinkaurelius" level="WARN" additivity="false"> - <appender-ref ref="rshipTool"/> - <appender-ref ref="rshipTooldebug"/> - <appender-ref ref="rshipToolmetric"/> - </logger> - <logger name="ch.qos.logback.classic" level="WARN" additivity="false"> - <appender-ref ref="rshipTool"/> - <appender-ref ref="rshipTooldebug"/> - <appender-ref ref="rshipToolmetric"/> - </logger> - <logger name="ch.qos.logback.core" level="WARN" additivity="false"> - <appender-ref ref="rshipTool"/> - <appender-ref ref="rshipTooldebug"/> - <appender-ref ref="rshipToolmetric"/> - </logger> - <logger name="com.att.eelf" level="WARN" additivity="false"> - <appender-ref ref="rshipTool"/> - <appender-ref ref="rshipTooldebug"/> - <appender-ref ref="rshipToolmetric"/> - </logger> - <logger name="org.onap.aai" level="INFO" additivity="false"> - <appender-ref ref="rshipTool"/> - <appender-ref ref="rshipTooldebug"/> - <appender-ref ref="rshipToolmetric"/> - </logger> - - <root level="INFO"> - <appender-ref ref="rshipTool"/> - <appender-ref ref="rshipTooldebug"/> - <appender-ref ref="rshipToolmetric"/> - <appender-ref ref="STDOUT"/> - </root> -</configuration> diff --git a/aai-resources/bundleconfig-local/etc/appprops/updtool-logback.xml b/aai-resources/bundleconfig-local/etc/appprops/updtool-logback.xml deleted file mode 100644 index 6bc0a27..0000000 --- a/aai-resources/bundleconfig-local/etc/appprops/updtool-logback.xml +++ /dev/null @@ -1,123 +0,0 @@ -<!-- - - ============LICENSE_START======================================================= - org.onap.aai - ================================================================================ - Copyright © 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 is a trademark and service mark of AT&T Intellectual Property. - ---> -<configuration> - <property name="logDirectory" value="${AJSC_HOME}/logs" /> - <property name="eelfLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - <property name="eelfMetricLogPattern" value="%ecompStartTime|%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ, UTC}|%X{requestId}|%X{serviceInstanceId}|%-10t|%X{serverName}|%X{serviceName}|%X{partnerName}|%X{targetEntity}|%X{targetServiceName}|%X{statusCode}|%X{responseCode}|%replace(%replace(%X{responseDescription}){'\\|', '!'}){'\r|\n', '^'}|%X{instanceUUID}|%level|%X{severity}|%X{serverIpAddress}|%ecompElapsedTime|%X{server}|%X{clientIpAddress}|%eelfClassOfCaller|%X{unused}|%X{processKey}|%X{targetVirtualEntity}|%X{customField1}|%X{customField2}|%X{customField3}|%X{customField4}|co=%X{component}:%replace(%replace(%m){'\\|', '!'}){'\r|\n', '^'}%n"/> - - <appender name="updTool" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>WARN</level> - </filter> - <File>${logDirectory}/updTool/error.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/updTool/error.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="updTooldebug" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>DEBUG</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/updTool/debug.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/updTool/debug.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfLogPattern}</pattern> - </encoder> - </appender> - - <appender name="updToolmetric" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <File>${logDirectory}/updTool/metrics.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>${logDirectory}/updTool/metrics.log.%d{yyyy-MM-dd}</fileNamePattern> - </rollingPolicy> - <encoder class="org.onap.aai.logging.EcompEncoder"> - <pattern>${eelfMetricLogPattern}</pattern> - </encoder> - </appender> - - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder>%-4relative [%thread] %-5level %logger{35} - %msg %n</encoder> - </appender> - - <logger name="org.reflections" level="WARN" additivity="false"> - <appender-ref ref="updTool"/> - <appender-ref ref="updTooldebug"/> - <appender-ref ref="updToolmetric"/> - </logger> - <logger name="org.apache.zookeeper" level="WARN" additivity="false"> - <appender-ref ref="updTool"/> - <appender-ref ref="updTooldebug"/> - <appender-ref ref="updToolmetric"/> - </logger> - <logger name="org.apache.hadoop" level="WARN" additivity="false"> - <appender-ref ref="updTool"/> - <appender-ref ref="updTooldebug"/> - <appender-ref ref="updToolmetric"/> - </logger> - <logger name="com.thinkaurelius" level="WARN" additivity="false"> - <appender-ref ref="updTool"/> - <appender-ref ref="updTooldebug"/> - <appender-ref ref="updToolmetric"/> - </logger> - <logger name="ch.qos.logback.classic" level="WARN" additivity="false"> - <appender-ref ref="updTool"/> - <appender-ref ref="updTooldebug"/> - <appender-ref ref="updToolmetric"/> - </logger> - <logger name="ch.qos.logback.core" level="WARN" additivity="false"> - <appender-ref ref="updTool"/> - <appender-ref ref="updTooldebug"/> - <appender-ref ref="updToolmetric"/> - </logger> - <logger name="com.att.eelf" level="WARN" additivity="false"> - <appender-ref ref="updTool"/> - <appender-ref ref="updTooldebug"/> - <appender-ref ref="updToolmetric"/> - </logger> - <logger name="org.onap.aai" level="INFO" additivity="false"> - <appender-ref ref="updTool"/> - <appender-ref ref="updTooldebug"/> - <appender-ref ref="updToolmetric"/> - </logger> - - <root level="INFO"> - <appender-ref ref="updTool"/> - <appender-ref ref="updTooldebug"/> - <appender-ref ref="updToolmetric"/> - <appender-ref ref="STDOUT"/> - </root> -</configuration> diff --git a/aai-resources/src/main/scripts/deleteTool.sh b/aai-resources/src/main/scripts/deleteTool.sh new file mode 100644 index 0000000..b9ee8b0 --- /dev/null +++ b/aai-resources/src/main/scripts/deleteTool.sh @@ -0,0 +1,148 @@ +#!/bin/ksh + +### +# ============LICENSE_START======================================================= +# org.onap.aai +# ================================================================================ +# 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========================================================= +### + +# +# The script is called with a resource to be deleted. +# Uses aaiconfig.properties for authorization type and url. +# It invokes a GET on the resource using curl and parses the resource-version. +# If found, prompts the user to continue and invokes DELETE using curl. +# responses in the range of 200 to 299 are considered successful +# + +display_usage() { + cat <<EOF + Usage: $0 [options] + + 1. Usage: deleteTool.sh <resource-path> + 2. This script needs only one argument and the argument should be resource-path. + 3. for example: resource-path for a particular customer is business/customers/customer/global-customer-id-1 + 4. If resource is found, user will be prompted for confirmation to delete (y/n) + 5. Press any key other than "y" to cancel deletion of resource +EOF +} +if [ $# -eq 0 ]; then + display_usage + exit 1 +fi + +# remove leading slash when present +RESOURCE=`echo $1 | sed "s,^/,,"` +if [ -z $RESOURCE ]; then + echo "resource parameter is missing" + echo "usage: $0 resource" + exit 1 +fi +echo `date` " Starting $0 for resource $RESOURCE" + +XFROMAPPID="AAI-TOOLS" +XTRANSID=`uuidgen` +XTRANSID1=`uuidgen` + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh +PROJECT_HOME=/opt/app/aai-resources +prop_file=$PROJECT_HOME/bundleconfig/etc/appprops/aaiconfig.properties +log_dir=$PROJECT_HOME/logs/misc +today=$(date +\%Y-\%m-\%d) + +MISSING_PROP=false +RESTURL=`grep ^aai.server.url= $prop_file |cut -d'=' -f2 |tr -d "\015"` +if [ -z $RESTURL ]; then + echo "Property [aai.server.url] not found in file $prop_file" + MISSING_PROP=true +fi +USEBASICAUTH=false +BASICENABLE=`grep ^aai.tools.enableBasicAuth $prop_file |cut -d'=' -f2 |tr -d "\015"` +if [ -z $BASICENABLE ]; then + USEBASICAUTH=false +else + USEBASICAUTH=true + CURLUSER=`grep ^aai.tools.username $prop_file |cut -d'=' -f2 |tr -d "\015"` + if [ -z $CURLUSER ]; then + echo "Property [aai.tools.username] not found in file $prop_file" + MISSING_PROP=true + fi + CURLPASSWORD=`grep ^aai.tools.password $prop_file |cut -d'=' -f2 |tr -d "\015"` + if [ -z $CURLPASSWORD ]; then + echo "Property [aai.tools.password] not found in file $prop_file" + MISSING_PROP=true + fi +fi + +if [ $MISSING_PROP = false ]; then + if [ $USEBASICAUTH = false ]; then + AUTHSTRING="--cert $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPublicCert.pem --key $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPrivateKey.pem" + else + AUTHSTRING="-u $CURLUSER:$CURLPASSWORD" + fi + RESOURCEVERSION=`curl --request GET -sL -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID1" -H "Accept: application/json" $RESTURL$RESOURCE|awk -F"\"resource-version\":\"" '{print $2}' | cut -d\" -f1` + echo "resource-version is" $RESOURCEVERSION + if [ -z $RESOURCEVERSION ]; then + echo "failed to get resource-version for $RESOURCE" + echo `date` " Done $0, returning -1" + exit -1 + fi + echo "Are you sure you would like to delete $RESOURCE? (y, n)" + read USERINPUT + if [ "$USERINPUT" != "y" ]; then + echo "user chose to exit before delete" + echo `date` " Done $0, returning -1" + exit -1 + fi + + result=`curl --request DELETE -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" $RESTURL$RESOURCE?resource-version=$RESOURCEVERSION` + echo "result is $result." + RC=0; + if [ $? -eq 0 ]; then + case $result in + +([0-9])?) + if [[ "$result" -ge 200 && $result -lt 300 ]] + then + echo "DELETE result is OK, $result" + else + echo "failed DELETE request, response code was $result" + RC=$result + fi + ;; + *) + echo "DELETE request failed, response was $result" + RC=-1 + ;; + + esac + else + echo "FAILED to send request to $RESTURL" + RC=-1 + fi +else + echo "usage: $0 resource" + RC=-1 +fi + +echo +echo `date` " Done $0, returning $RC" +exit $RC diff --git a/aai-resources/src/main/scripts/getTool.sh b/aai-resources/src/main/scripts/getTool.sh new file mode 100644 index 0000000..8d006b0 --- /dev/null +++ b/aai-resources/src/main/scripts/getTool.sh @@ -0,0 +1,106 @@ +#!/bin/ksh + +### +# ============LICENSE_START======================================================= +# org.onap.aai +# ================================================================================ +# 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========================================================= +### + +# +# The script is called with a resource. +# It invokes a GET on the resource using curl +# Uses aaiconfig.properties for authorization type and url. + +display_usage() { + cat <<EOF + Usage: $0 [options] + + 1. Usage: getTool.sh <resource-path> + 2. This script needs only one argument and the argument should be resource-path. + 3. for example: resource-path for a particular customer is business/customers/customer/global-customer-id-1 +EOF +} +if [ $# -eq 0 ]; then + display_usage + exit 1 +fi + +# remove leading slash when present +RESOURCE=$(echo $1 | sed "s,^/,,") + +if [ -z $RESOURCE ]; then + echo "resource parameter is missing" + echo "usage: $0 resource file [expected-failure-codes]" + exit 1 +fi +echo `date` " Starting $0 for resource $RESOURCE" + +XFROMAPPID="AAI-TOOLS" +XTRANSID=`uuidgen` + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh +PROJECT_HOME=/opt/app/aai-resources +prop_file=$PROJECT_HOME/bundleconfig/etc/appprops/aaiconfig.properties +log_dir=$PROJECT_HOME/logs/misc +today=$(date +\%Y-\%m-\%d) + + +MISSING_PROP=false +RESTURL=$(grep ^aai.server.url= $prop_file |cut -d'=' -f2 |tr -d "\015") +if [ -z $RESTURL ]; then + echo "Property [aai.server.url] not found in file $prop_file" + MISSING_PROP=true +fi +USEBASICAUTH=false +BASICENABLE=$(grep ^aai.tools.enableBasicAuth $prop_file |cut -d'=' -f2 |tr -d "\015") +if [ -z $BASICENABLE ]; then + USEBASICAUTH=false +else + USEBASICAUTH=true + CURLUSER=$(grep ^aai.tools.username $prop_file |cut -d'=' -f2 |tr -d "\015") + if [ -z $CURLUSER ]; then + echo "Property [aai.tools.username] not found in file $prop_file" + MISSING_PROP=true + fi + CURLPASSWORD=$(grep ^aai.tools.password $prop_file |cut -d'=' -f2 |tr -d "\015") + if [ -z $CURLPASSWORD ]; then + echo "Property [aai.tools.password] not found in file $prop_file" + MISSING_PROP=true + fi +fi + +if [ $MISSING_PROP = false ]; then + if [ $USEBASICAUTH = false ]; then + AUTHSTRING="--cert $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPublicCert.pem --key $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPrivateKey.pem" + else + AUTHSTRING="-u $CURLUSER:$CURLPASSWORD" + fi + curl --request GET -sL -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" $RESTURL$RESOURCE | python -mjson.tool + RC=$?; +else + echo "usage: $0 resource" + RC=-1 +fi + +echo `date` " Done $0, returning $RC" +exit $RC diff --git a/aai-resources/src/main/scripts/putTool.sh b/aai-resources/src/main/scripts/putTool.sh new file mode 100644 index 0000000..dfa9b37 --- /dev/null +++ b/aai-resources/src/main/scripts/putTool.sh @@ -0,0 +1,161 @@ +#!/bin/ksh + +### +# ============LICENSE_START======================================================= +# org.onap.aai +# ================================================================================ +# 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========================================================= +### + +# +# The script is called with a resource, filepath and an optional argument to +# ignore HTTP failure codes which would otherwise indicate a failure. +# It invokes a PUT on the resource with the file using curl +# Uses aaiconfig.properties for authorization type and url. The HTTP response +# code is checked. Responses between 200 and 299 are considered success. +# When the ignore failure code parameter is passed, responses outside of +# the 200 to 299 range but matching a sub-string of the parameter are +# considered success. For example, a parameter value of 412 will consider +# responses in the range of 200 to 299 and 412 successes. +# +# method checking parameter list for two strings, and determine if +# the second string is a sub-string of the first +contains() { + string="$1" + substring="$2" + if test "${string#*$substring}" != "$string" + then + return 0 # $substring is in $string + else + return 1 # $substring is not in $string + fi +} + +display_usage() { + cat <<EOF + Usage: $0 [options] + + 1. Usage: putTool.sh <resource-path> <json payload file> + 2. This script requires two arguments, a resource path and a file path to a json file containing the payload. + 3. Example: resource-path and payload for a particular customer is: business/customers/customer/JohnDoe customerpayload.json +EOF +} +if [ $# -eq 0 ]; then + display_usage + exit 1 +fi + +# remove leading slash when present +RESOURCE=`echo $1 | sed "s,^/,,"` +if [ -z $RESOURCE ]; then + echo "resource parameter is missing" + echo "usage: $0 resource file [expected-failure-codes]" + exit 1 +fi +JSONFILE=$2 +if [ -z $JSONFILE ]; then + echo "json file parameter is missing" + echo "usage: $0 resource file [expected-failure-codes]" + exit 1 +fi +echo `date` " Starting $0 for resource $RESOURCE" +ALLOWHTTPRESPONSES=$3 + +XFROMAPPID="AAI-TOOLS" +XTRANSID=`uuidgen` + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh +PROJECT_HOME=/opt/app/aai-resources +prop_file=$PROJECT_HOME/bundleconfig/etc/appprops/aaiconfig.properties +log_dir=$PROJECT_HOME/logs/misc +today=$(date +\%Y-\%m-\%d) + +MISSING_PROP=false +RESTURL=`grep ^aai.server.url= $prop_file |cut -d'=' -f2 |tr -d "\015"` +if [ -z $RESTURL ]; then + echo "Property [aai.server.url] not found in file $prop_file" + MISSING_PROP=true +fi +USEBASICAUTH=false +BASICENABLE=`grep ^aai.tools.enableBasicAuth $prop_file |cut -d'=' -f2 |tr -d "\015"` +if [ -z $BASICENABLE ]; then + USEBASICAUTH=false +else + USEBASICAUTH=true + CURLUSER=`grep ^aai.tools.username $prop_file |cut -d'=' -f2 |tr -d "\015"` + if [ -z $CURLUSER ]; then + echo "Property [aai.tools.username] not found in file $prop_file" + MISSING_PROP=true + fi + CURLPASSWORD=`grep ^aai.tools.password $prop_file |cut -d'=' -f2 |tr -d "\015"` + if [ -z $CURLPASSWORD ]; then + echo "Property [aai.tools.password] not found in file $prop_file" + MISSING_PROP=true + fi +fi + +if [ $MISSING_PROP = false ]; then + if [ $USEBASICAUTH = false ]; then + AUTHSTRING="--cert $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPublicCert.pem --key $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPrivateKey.pem" + else + AUTHSTRING="-u $CURLUSER:$CURLPASSWORD" + fi + result=`curl --request PUT -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE` + #echo "result is $result." + RC=0; + if [ $? -eq 0 ]; then + case $result in + +([0-9])?) + if [[ "$result" -ge 200 && $result -lt 300 ]] + then + echo "PUT result is OK, $result" + else + if [ -z $ALLOWHTTPRESPONSES ]; then + echo "PUT request failed, response code was $result" + RC=$result + else + contains $ALLOWHTTPRESPONSES $result + if [ $? -ne 0 ] + then + echo "PUT request failed, unexpected response code was $result" + RC=$result + else + echo "PUT result is expected, $result" + fi + fi + fi + ;; + *) + echo "PUT request failed, response was $result" + RC=-1 + ;; + + esac + else + echo "FAILED to send request to $RESTURL" + RC=-1 + fi +else + echo "usage: $0 resource file [expected-failure-codes]" + RC=-1 +fi + +echo `date` " Done $0, returning $RC" +exit $RC
\ No newline at end of file diff --git a/aai-resources/src/main/scripts/rshipTool.sh b/aai-resources/src/main/scripts/rshipTool.sh new file mode 100644 index 0000000..8decd04 --- /dev/null +++ b/aai-resources/src/main/scripts/rshipTool.sh @@ -0,0 +1,226 @@ +#!/bin/ksh + +### +# ============LICENSE_START======================================================= +# org.onap.aai +# ================================================================================ +# 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========================================================= +### + +# +# The script invokes RelationshipputDel java class to PUT/DELETE a relationship +# +# sample json file for an oam-network node to put a relationship to a complex +#{ +# "related-to": "complex", +# "relationship-data": [ { +# "relationship-key": "complex.physical-location-id", +# "relationship-value": "CHCGILCL73W" +# }] +#} +# +# method checking parameter list for two strings, and determine if +# the second string is a sub-string of the first +contains() { + string="$1" + substring="$2" + if test "${string#*$substring}" != "$string" + then + return 0 # $substring is in $string + else + + return 1 # $substring is not in $string + fi +} + +display_usage() { + cat <<EOF + Usage: $0 [options] + + 1. Usage: rshipTool.sh <action> <resource-path> <json-file> + 2. This script needs 3 arguments, and the arguments should be an action, a resource-path and a json file. + 3. example action: PUT or DELETE + 4. example resource path: cloud-infrastructure/pservers/pserver/{hostname}/relationship-list/relationships + 5. example json file name: json file argument should be the location of the file such as /tmp/jsonFile.json + 6. example: format for json file contents + {"related-to": "complex", + "relationship-data": [ { + "relationship-key": "complex.physical-location-id", + "relationship-value": "CHCGILCL73W" + }]} +EOF +} + +if [ $# -eq 0 ]; then + display_usage + exit 1 +fi + +# Check to see if PUT or DELETE +ACTION=$(echo $1 | tr '[:lower:]' '[:upper:]') +if [ "$ACTION" != "PUT" ]; then + if [ "$ACTION" != "DELETE" ]; then + echo "Method: $1 is an Invalid arguments for $0" + exit 1 + fi +fi + +# remove leading slash when present +RESOURCE=$(echo $2 | sed "s,^/,,") + +if [ -z $RESOURCE ]; then + echo "resource parameter is missing" + echo "usage: $0 resource file [expected-failure-codes]" + exit 1 +fi +echo `date` " Starting $0 for resource $RESOURCE" + +RELATIONSHIP="" +contains $RESOURCE "/relationship-list/relationship" +if [ $? -ne 0 ]; then + RELATIONSHIP="/relationship-list/relationship" +fi + +JSONFILE=$3 +if [ -z $JSONFILE ]; then + echo "json file parameter is missing" + echo "usage: $0 resource file [expected-failure-codes]" + exit 1 +fi +ALLOWHTTPRESPONSES=$4 + +XFROMAPPID="AAI-TOOLS" +XTRANSID=`uuidgen` + +userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) +if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 +fi + +. /etc/profile.d/aai.sh +PROJECT_HOME=/opt/app/aai-resources +prop_file=$PROJECT_HOME/bundleconfig/etc/appprops/aaiconfig.properties +log_dir=$PROJECT_HOME/logs/misc +today=$(date +\%Y-\%m-\%d) + + +MISSING_PROP=false +RESTURL=$(grep ^aai.server.url= $prop_file |cut -d'=' -f2 |tr -d "\015") +if [ -z $RESTURL ]; then + echo "Property [aai.server.url] not found in file $prop_file" + MISSING_PROP=true +fi +USEBASICAUTH=false +BASICENABLE=$(grep ^aai.tools.enableBasicAuth $prop_file |cut -d'=' -f2 |tr -d "\015") +if [ -z $BASICENABLE ]; then + USEBASICAUTH=false +else + USEBASICAUTH=true + CURLUSER=$(grep ^aai.tools.username $prop_file |cut -d'=' -f2 |tr -d "\015") + if [ -z $CURLUSER ]; then + echo "Property [aai.tools.username] not found in file $prop_file" + MISSING_PROP=true + fi + CURLPASSWORD=$(grep ^aai.tools.password $prop_file |cut -d'=' -f2 |tr -d "\015") + if [ -z $CURLPASSWORD ]; then + echo "Property [aai.tools.password] not found in file $prop_file" + MISSING_PROP=true + fi +fi + +if [ $MISSING_PROP = false ]; then + if [ $USEBASICAUTH = false ]; then + AUTHSTRING="--cert $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPublicCert.pem --key $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPrivateKey.pem" + else + AUTHSTRING="-u $CURLUSER:$CURLPASSWORD" + fi + + RESOURCEVERSION=$(curl --request GET -sL -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" $RESTURL$RESOURCE | python -c "import sys, json; print json.load(sys.stdin)['resource-version']") + if [ $ACTION = "PUT" ]; then + result=`curl --request PUT -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE$RELATIONSHIP?$RESOURCEVERSION` + #echo "result is $result." + RC=0; + if [ $? -eq 0 ]; then + case $result in + +([0-9])?) + #if [[ "$result" -eq 412 || "$result" -ge 200 && $result -lt 300 ]] + if [[ "$result" -ge 200 && $result -lt 300 ]] + then + echo "PUT result is OK, $result" + curl --request GET -sL -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" $RESTURL$RESOURCE | python -mjson.tool + else + if [ -z $ALLOWHTTPRESPONSES ]; then + echo "PUT request failed, response code was $result" + RC=$result + else + contains $ALLOWHTTPRESPONSES $result + if [ $? -ne 0 ] + then + echo "PUT request failed, unexpected response code was $result" + RC=$result + else + echo "PUT result is expected, $result" + fi + fi + fi + ;; + *) + echo "PUT request failed, response was $result" + RC=-1 + ;; + + esac + else + echo "FAILED to send request to $RESTURL" + RC=-1 + fi + else + result=`curl --request DELETE -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE$RELATIONSHIP?$RESOURCEVERSION` + echo "result is $result." + RC=0; + if [ $? -eq 0 ]; then + case $result in + +([0-9])?) + if [[ "$result" -ge 200 && $result -lt 300 ]] + then + echo "DELETE result is OK, $result" + curl --request GET -sL -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" $RESTURL$RESOURCE | python -mjson.tool + else + echo "failed DELETE request, response code was $result" + RC=$result + fi + ;; + *) + echo "DELETE request failed, response was $result" + RC=-1 + ;; + + esac + else + echo "FAILED to send request to $RESTURL" + RC=-1 + fi + + fi + +else + echo "usage: $0 resource" + RC=-1 +fi + +echo `date` " Done $0, returning $RC" +exit $RC
\ No newline at end of file diff --git a/aai-resources/src/main/scripts/updateTool.sh b/aai-resources/src/main/scripts/updateTool.sh index 9e93488..f4e2941 100644 --- a/aai-resources/src/main/scripts/updateTool.sh +++ b/aai-resources/src/main/scripts/updateTool.sh @@ -22,37 +22,210 @@ # # -# The script invokes GetResource java class to get all nodes +# For Usage 1, the script is called with a resource, filepath and an optional argument to +# ignore HTTP failure codes which would otherwise indicate a failure. +# It invokes a PATCH on the resource with the file using curl +# Uses aaiconfig.properties for authorization type and url. The HTTP response +# code is checked. Responses between 200 and 299 are considered success. +# When the ignore failure code parameter is passed, responses outside of +# the 200 to 299 range but matching a sub-string of the parameter are +# considered success. For example, a parameter value of 412 will consider +# responses in the range of 200 to 299 and 412 successes. # +# method checking parameter list for two strings, and determine if +# the second string is a sub-string of the first +contains() { + string="$2" + substring="$3" + if test "${string#*$substring}" != "$string" + then + return 0 # $substring is in $string + else + return 1 # $substring is not in $string + fi +} -echo -echo `date` " Starting $0" +display_usage() { +cat <<EOF +Usage: $0 [options] + +1. This script needs a resource argument (resource-path), and either a JSON filepath, or directly the property you need to update +2. Usage 1 (use a Json file): updateTool.sh <node type> <resource> <filepath> <optional arg to ignore HTTP failure codes> +3. Usage 1 example: ./updateTool.sh customer business/customers/customer/customer-id-1 /tmp/updateTest.json + +4. Usage 2 (update a property directly): updateTool.sh <node type> <resource> '<key name>:<key value>,<property>:<property val>' <optional arg to ignore HTTP failure codes> +5. Usage 2 example: ./updateTool.sh complex cloud-infrastructure/complexes/complex/complex-id 'physical-location-id:complex-id, city:New York' +6. You could try without the <key name>:<key value> (only the property and its new value), but on some servers this did not work: +7. ./updateTool.sh complex cloud-infrastructure/complexes/complex/complex-id 'city:New York' + +8. Usage 3 (update an attribute on an object that is embedded a level or two levels. Use the full path) +9. ./updateTool.sh <node type> <embedded resource with full paths> <key name: key value> +10. ./updateTool.sh p-interface network/pnfs/pnf/pnf-name-1/p-interfaces/p-interface/int-1 'interface-type:int-typei' +EOF +} + +if [ $# -eq 0 ]; then +display_usage +exit 1 +fi + +# remove leading slash when present +RESOURCE=`echo $2 | sed "s,^/,,"` + +if [ -z $RESOURCE ]; then + echo "resource parameter is missing" + echo "usage: $0 resource file [expected-failure-codes]" + exit 1 +fi + +JSONFILE=$3 +if [ -z $JSONFILE ]; then + echo "json file or input parameter is missing" + echo "usage: $0 resource <file or command-line input>[expected-failure-codes]" + exit 1 +fi +echo `date` " Starting $0 for resource $RESOURCE" +ALLOWHTTPRESPONSES=$4 + +XFROMAPPID="AAI-TOOLS" +XTRANSID=`uuidgen` userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) if [ "${userid}" != "aaiadmin" ]; then echo "You must be aaiadmin to run $0. The id used $userid." exit 1 -fi +fi . /etc/profile.d/aai.sh PROJECT_HOME=/opt/app/aai-resources +prop_file=$PROJECT_HOME/bundleconfig/etc/appprops/aaiconfig.properties +log_dir=$PROJECT_HOME/logs/misc +today=$(date +\%Y-\%m-\%d) + +MISSING_PROP=false +RESTURL=`grep ^aai.server.url= $prop_file |cut -d'=' -f2 |tr -d "\015"` +if [ -z $RESTURL ]; then + echo "Property [aai.server.url] not found in file $prop_file" + MISSING_PROP=true +fi +USEBASICAUTH=false +BASICENABLE=`grep ^aai.tools.enableBasicAuth $prop_file |cut -d'=' -f2 |tr -d "\015"` +if [ -z $BASICENABLE ]; then + USEBASICAUTH=false +else + USEBASICAUTH=true + CURLUSER=`grep ^aai.tools.username $prop_file |cut -d'=' -f2 |tr -d "\015"` + if [ -z $CURLUSER ]; then + echo "Property [aai.tools.username] not found in file $prop_file" + MISSING_PROP=true + fi + CURLPASSWORD=`grep ^aai.tools.password $prop_file |cut -d'=' -f2 |tr -d "\015"` + if [ -z $CURLPASSWORD ]; then + echo "Property [aai.tools.password] not found in file $prop_file" + MISSING_PROP=true + fi +fi + +#determine if the 3rd arg is +#/tmp/updateTest.json +#or +#'physical-location-id:complex-id, city:New York' +thirdarg=$3 +isjson = true +if [[ "$thirdarg" == *json || "$thirdarg" == *JSON ]]; then + echo "Usage 1(JSON) because the 2nd arg ends with json"; +else + echo "Usage 2(Comand Arg) because the 2nd arg does not end with json"; + #For Usage 2, format input into JSON string format + JSONSTRING="{" + INPUT=$3 + + #replace any spaces with %20 + INPUT=${INPUT// /%20} + + for i in ${INPUT//,/ }; + do + #change any %20 back to space ) + i=${i//%20/ } + #echo "after change to space=$i" + + #trim modstring to remove any beginning spaces (" city" becomes "city") + i="${i##*( )}" + + #add JSON quotes + MODSTRING=" \"$i\"," + + MODSTRING=${MODSTRING//[:]/'": "'} + #echo "MODSTRING=$MODSTRING" + + JSONSTRING+=$MODSTRING + done + JSONSTRING="${JSONSTRING%?}" + JSONSTRING+=" }" + echo "JSON string is $JSONSTRING" +fi -for JAR in `ls $PROJECT_HOME/extJars/*.jar` -do - CLASSPATH=$CLASSPATH:$JAR -done +generate_data() +{ +cat <<EOF +$JSONSTRING +EOF +} -for JAR in `ls $PROJECT_HOME/lib/*.jar` -do - CLASSPATH=$CLASSPATH:$JAR -done +if [ $MISSING_PROP = false ]; then + if [ $USEBASICAUTH = false ]; then + AUTHSTRING="--cert $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPublicCert.pem --key $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPrivateKey.pem" + else + AUTHSTRING="-u $CURLUSER:$CURLPASSWORD" + fi + + if [[ "$thirdarg" == *json || "$thirdarg" == *JSON ]]; then + ##Usage 1 (JSON file) + result=`curl --request PATCH -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Content-Type: application/merge-patch+json" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE`; + else + #Usage 2 (command-line argument) + result=`curl --request PATCH -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Content-Type: application/merge-patch+json" -H "Accept: application/json" --data "$(generate_data)" $RESTURL$RESOURCE` + + fi + echo "result is $result." + RC=0; + if [ $? -eq 0 ]; then + case $result in + +([0-9])?) + #if [[ "$result" -eq 412 || "$result" -ge 200 && $result -lt 300 ]] + if [[ "$result" -ge 200 && $result -lt 300 ]] + then + echo "PATCH result is OK, $result" + else + if [ -z $ALLOWHTTPRESPONSES ]; then + echo "PATCH request failed, response code was $result" + RC=$result + else + contains $ALLOWHTTPRESPONSES $result + if [ $? -ne 0 ] + then + echo "PATCH request failed, unexpected response code was $result" + RC=$result + else + echo "PATCH result is expected, $result" + fi + fi + fi + ;; + *) + echo "PATCH request failed, response was $result" + RC=-1 + ;; -$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME org.onap.aai.util.UpdateResource "$@" -ret_code=$? -if [ $ret_code != 0 ]; then - echo `date` " Done $0" - exit $ret_code + esac + else + echo "FAILED to send request to $RESTURL" + RC=-1 + fi +else + echo "usage: $0 resource file [expected-failure-codes]" + RC=-1 fi -echo `date` " Done $0" -exit 0 +echo `date` " Done $0, returning $RC" +exit $RC
\ No newline at end of file |