summaryrefslogtreecommitdiffstats
path: root/asdctool/src/main/resources/es-resources
diff options
context:
space:
mode:
authorys9693 <ys9693@att.com>2020-01-19 13:50:02 +0200
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-01-22 12:33:31 +0000
commit16a9fce0e104a38371a9e5a567ec611ae3fc7f33 (patch)
tree03a2aff3060ddb5bc26a90115805a04becbaffc9 /asdctool/src/main/resources/es-resources
parentaa83a2da4f911c3ac89318b8e9e8403b072942e1 (diff)
Catalog alignment
Issue-ID: SDC-2724 Signed-off-by: ys9693 <ys9693@att.com> Change-Id: I52b4aacb58cbd432ca0e1ff7ff1f7dd52099c6fe
Diffstat (limited to 'asdctool/src/main/resources/es-resources')
-rw-r--r--asdctool/src/main/resources/es-resources/README.txt43
-rw-r--r--asdctool/src/main/resources/es-resources/auditMappings.txt169
-rw-r--r--asdctool/src/main/resources/es-resources/audit_migration_1602.py132
-rw-r--r--asdctool/src/main/resources/es-resources/config_properties.py11
-rw-r--r--asdctool/src/main/resources/es-resources/file_utils.py21
-rw-r--r--asdctool/src/main/resources/es-resources/index_ops.py151
-rw-r--r--asdctool/src/main/resources/es-resources/types/auditinggetuebclusterevent.txt8
-rw-r--r--asdctool/src/main/resources/es-resources/types/distributiondeployevent.txt14
-rw-r--r--asdctool/src/main/resources/es-resources/types/distributiondownloadevent.txt9
-rw-r--r--asdctool/src/main/resources/es-resources/types/distributionengineevent.txt13
-rw-r--r--asdctool/src/main/resources/es-resources/types/distributionnotificationevent.txt16
-rw-r--r--asdctool/src/main/resources/es-resources/types/distributionstatusevent.txt12
-rw-r--r--asdctool/src/main/resources/es-resources/types/resourceadminevent.txt21
-rw-r--r--asdctool/src/main/resources/es-resources/types/useraccessevent.txt10
-rw-r--r--asdctool/src/main/resources/es-resources/types/useradminevent.txt20
15 files changed, 0 insertions, 650 deletions
diff --git a/asdctool/src/main/resources/es-resources/README.txt b/asdctool/src/main/resources/es-resources/README.txt
deleted file mode 100644
index a7006efa80..0000000000
--- a/asdctool/src/main/resources/es-resources/README.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-ASDC elasticsearch tool
-========================
-
-This tool purpose is to ease and allow updating elasticsearch indices.
-
-In order to use the scripts, you need to verify Python is installed and to install the elasticsearc-py library:
- Verify pip is installed: $command -v pip
- if not installed:
- Download https://bootstrap.pypa.io/get-pip.py
- $python get-pip.py (see instruction: https://pip.pypa.io/en/latest/installing/#installing-with-get-pip-py)
- $pip install elasticsearch
-
-
-Tool contains:
- - index_ops.py
- This script includes operations on elasticsearch index:
-
- create index:
- $python index_ops.py -o create -a <elasticsearch hostname> -n <indexName> -f <index mapping file>
-
- delete index:
- $python index_ops.py -o delete -a <elasticsearch hostname> -n <indexName>
-
- copy index (assumes destination index already exists):
- $python index_ops.py -o move -a <elasticsearch hostname> -n <indexName> -t <toIndex>
-
-
- - file_utils.py
- This script includes operations on files
-
- - audit_migration_1602.py
- This script run full flow to migrate audit information from previous versions to ASDC 1602
- It has 2 inputs:
- 1. config_properties.py - this file holds configuration (hostname, index name, index mapping file etc.)
- 2. folder of fields mapping per elasticsearch type (map old field to new field)
- The flow of this script is as follow:
- * create temp index with correct index mapping
- * scan the audit index to get all records
- * manipulate fields data and insert it to temp index
- * delete audit index
- * create audit index with correct mapping
- * copy from temp index to newly created audit index
- * delete temp index \ No newline at end of file
diff --git a/asdctool/src/main/resources/es-resources/auditMappings.txt b/asdctool/src/main/resources/es-resources/auditMappings.txt
deleted file mode 100644
index 7de77cccbd..0000000000
--- a/asdctool/src/main/resources/es-resources/auditMappings.txt
+++ /dev/null
@@ -1,169 +0,0 @@
-{ "settings": {}, "mappings":
-{
-"distributiondownloadevent":
-{ "properties": {
- "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS", "precision_step": 4, "type": "date" },
- "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "DESC": { "include_in_all": true, "type": "string" },
- "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "RESOURCE_URL": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "CONSUMER_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }},
- "_all": { "enabled": true } },
- "auditinggetuebclusterevent":
-{ "properties": {
- "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS", "precision_step": 4, "type": "date" },
- "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "DESC": { "include_in_all": true, "type": "string" },
- "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "CONSUMER_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }},
- "_all": { "enabled": true } },
- "distributionstatusevent":
-{ "properties": {
- "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS", "precision_step": 4, "type": "date" },
- "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "DESC": { "include_in_all": true, "type": "string" },
- "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "RESOURCE_URL": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "DID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "TOPIC_NAME":{ "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "CONSUMER_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }},
- "_all": { "enabled": true } },
-"distributionengineevent":
-{ "properties": {
- "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS", "precision_step": 4, "type": "date" },
- "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "DESC": { "include_in_all": true, "type": "string" },
- "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "TOPIC_NAME":{ "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "ROLE": { "include_in_all": true, "type": "string" },
- "API_KEY": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "D_ENV": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "CONSUMER_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }},
- "_all": { "enabled": true } },
- "useraccessevent": {
- "properties": {
- "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS", "precision_step": 4, "type": "date" },
- "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "DESC": { "include_in_all": true, "type": "string" },
- "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "USER_UID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "USER_NAME": { "include_in_all": true, "type": "string" }} ,
- "_all": { "enabled": true }},
- "resourceadminevent":
- { "properties": {
- "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS", "precision_step": 4, "type": "date" },
- "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "DESC": { "include_in_all": true, "type": "string" },
- "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "CURR_VERSION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "CURR_STATE": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "DID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "MODIFIER_NAME": { "include_in_all": true, "type": "string" },
- "PREV_VERSION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "MODIFIER_UID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "PREV_STATE": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "RESOURCE_NAME": { "include_in_all": true, "type": "string" },
- "RESOURCE_TYPE": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "DPREV_STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "DCURR_STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "COMMENT": { "include_in_all": true, "type": "string" },
- "ARTIFACT_NAME": { "include_in_all": true, "index": "not_analyzed", "type": "string" } },
- "_all": { "enabled": true }} ,
- "useradminevent":
- { "properties": {
- "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS", "precision_step": 4, "type": "date" },
- "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "DESC": { "include_in_all": true, "type": "string" },
- "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "MODIFIER_NAME": { "include_in_all": true, "type": "string" },
- "USER_EMAIL": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "USER_ROLE": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "USER_AFTER_EMAIL": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "USER_BEFORE_ROLE": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "USER_AFTER_ROLE": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "USER_UID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "USER_NAME": { "include_in_all": true, "type": "string" },
- "USER_BEFORE_NAME": { "include_in_all": true, "type": "string" },
- "USER_BEFORE_EMAIL": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "MODIFIER_UID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "USER_AFTER_NAME": { "include_in_all": true, "type": "string" } },
- "_all": { "enabled": true } },
-"distributionnotificationevent":
- {"properties":{
- "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS", "precision_step": 4, "type": "date" },
- "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "DESC": { "include_in_all": true, "type": "string" },
- "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "CURR_STATE": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "CURR_VERSION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "DID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "MODIFIER_NAME": { "include_in_all": true, "type": "string" },
- "MODIFIER_UID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "RESOURCE_NAME": { "include_in_all": true, "type": "string" },
- "RESOURCE_TYPE": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "TOPIC_NAME":{ "include_in_all": true, "index": "not_analyzed", "type": "string" }}},
-"categoryevent":
-{"properties":{
- "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "DESC": { "include_in_all": true, "type": "string" },
- "MODIFIER": { "include_in_all": true, "type": "string" },
- "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "CATEGORY_NAME": { "include_in_all": true, "type": "string" },
- "SUB_CATEGORY_NAME": { "include_in_all": true, "type": "string" },
- "GROUPING_NAME": { "include_in_all": true, "type": "string" },
- "RESOURCE_TYPE": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS", "precision_step": 4, "type": "date" }},
- "_all": { "enabled": true } },
- "authevent": {
- "properties": {
- "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS", "precision_step": 4, "type": "date" },
- "DESC": { "include_in_all": true, "type": "string" },
- "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "URL": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "USER": { "include_in_all": true, "type": "string" } ,
- "AUTH_STATUS": { "include_in_all": true, "index": "not_analyzed","type": "string" } ,
- "REALM": { "include_in_all": true, "index": "not_analyzed","type": "string" }} ,
- "_all": { "enabled": true }},
- "consumerevent":
- {"properties":{
- "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "MODIFIER": { "include_in_all": true, "type": "string" },
- "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "DESC": { "include_in_all": true, "type": "string" },
- "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "ECOMP_USER": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS", "precision_step": 4, "type": "date" }},
- "_all": { "enabled": true } },
- "distributiondeployevent":
- { "properties": {
- "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "CURR_VERSION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "DESC": { "include_in_all": true, "type": "string" },
- "DID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "MODIFIER_NAME": { "include_in_all": true, "type": "string" },
- "MODIFIER_UID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "RESOURCE_NAME": { "include_in_all": true, "type": "string" },
- "RESOURCE_TYPE": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
- "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS", "precision_step": 4, "type": "date" }}}}} \ No newline at end of file
diff --git a/asdctool/src/main/resources/es-resources/audit_migration_1602.py b/asdctool/src/main/resources/es-resources/audit_migration_1602.py
deleted file mode 100644
index 8b61ebfaf0..0000000000
--- a/asdctool/src/main/resources/es-resources/audit_migration_1602.py
+++ /dev/null
@@ -1,132 +0,0 @@
-import itertools
-import string
-import json
-from datetime import datetime
-from elasticsearch import Elasticsearch
-import elasticsearch
-import elasticsearch.helpers
-from elasticsearch.client import IndicesClient
-import sys, os
-from index_ops import createIndex, deleteIndex, copyIndex
-from config_properties import getGlobalVar
-from file_utils import readFileToJson
-
-def updateFieldNames(client, queryFrom, fromIndex, destIndex, addUTC):
- typesDir="types"
- typeFields = {}
- for filename in os.listdir(typesDir):
- print filename
- fieldNames=readFileToJson(typesDir+os.sep+filename)
-
- type=filename.split(".")[0]
- typeFields[type] = fieldNames
-
- client.indices.refresh(index=fromIndex)
- res = elasticsearch.helpers.scan(client, query=queryFrom, index=fromIndex)
-
- actions = []
- for i in res:
- res_type = i['_type']
- fieldNames = typeFields.get(res_type)
- if (fieldNames != None):
- action={}
- for field in i['_source']:
- updatedName=fieldNames.get(field)
- if (updatedName != None):
- if (field == 'timestamp' and addUTC == True):
- value+=" UTC"
- value=i['_source'].get(field)
- action[updatedName]=value
- else:
- action[field]=i['_source'].get(field)
- i['_source']=action
-
- i['_index']=destIndex
- i.pop('_id', None)
- actions.append(i)
-
- bulk_res = elasticsearch.helpers.bulk(client, actions)
- print "bulk response: ", bulk_res
-
-
-
-def updateAllrecordsWithUTC(client, queryFrom, fromIndex, destIndex):
-
- #scan indices
- client.indices.refresh(index=fromIndex)
- res = elasticsearch.helpers.scan(client, query=queryFrom, index=fromIndex)
-
- actions = []
- for i in res:
- print i
- i['_index']=destIndex
- i['_source']['TIMESTAMP']+=" UTC"
- actions.append(i)
-
- bulk_res = elasticsearch.helpers.bulk(client, actions)
- print "bulk response: ", bulk_res
-
-
-def printQueryResults(client, myQuery, indexName):
- client.indices.refresh(index=indexName)
- res = elasticsearch.helpers.scan(client, query=myQuery, index=indexName)
- for i in res:
- print i
-
-def main():
- print "start script for changing fields"
- print "================================="
-
- # initialize es
- es = Elasticsearch([getGlobalVar('host')])
-
- try:
- mapping=readFileToJson(getGlobalVar('mappingFileName'))
- res = createIndex(es, getGlobalVar('tempIndexName'), mapping)
- if (res != 0):
- print "script results in error"
- sys.exit(1)
-
- print "scan audit index and manipulate data"
- print "===================================="
-
- print "start time: ", datetime.now().time()
- updateFieldNames(es, getGlobalVar('matchAllQuery'), getGlobalVar('origIndexName'), getGlobalVar('tempIndexName'), getGlobalVar('addUTC'))
-
- print "re-create original index"
- print "========================="
- res = createIndex(es, getGlobalVar('origIndexName'), mapping)
- if (res != 0):
- print "script results in error"
- sys.exit(1)
-
- print "copy data from temp index to original"
- print "======================================="
- res = copyIndex(es, getGlobalVar('tempIndexName'), getGlobalVar('origIndexName'))
- if (res != 0):
- print "script results in error"
- sys.exit(1)
-
- print "delete temp index"
- print "=================="
- res = deleteIndex(es, getGlobalVar('tempIndexName'))
- if (res != 0):
- print "script results in error"
- sys.exit(1)
-
-
- print "end time: ", datetime.now().time()
-
- except Exception, error:
- print "An exception was thrown!"
- print str(error)
- return 2
-
-
-if __name__ == "__main__":
- main()
-
-
-
-
-
diff --git a/asdctool/src/main/resources/es-resources/config_properties.py b/asdctool/src/main/resources/es-resources/config_properties.py
deleted file mode 100644
index d0973001dc..0000000000
--- a/asdctool/src/main/resources/es-resources/config_properties.py
+++ /dev/null
@@ -1,11 +0,0 @@
-globalVars={
- "host": "127.0.0.1",
- "origIndexName": "temp_audit",
- "tempIndexName": "temp_audit2",
- "addUTC": False,
- "mappingFileName": "auditMappings.txt",
- "matchAllQuery":{"query": {"match_all": {}}}
-}
-
-def getGlobalVar(propertyName):
- return globalVars.get(propertyName) \ No newline at end of file
diff --git a/asdctool/src/main/resources/es-resources/file_utils.py b/asdctool/src/main/resources/es-resources/file_utils.py
deleted file mode 100644
index 743902084e..0000000000
--- a/asdctool/src/main/resources/es-resources/file_utils.py
+++ /dev/null
@@ -1,21 +0,0 @@
-import itertools
-import string
-import json
-from datetime import datetime
-from elasticsearch import Elasticsearch
-import elasticsearch
-import elasticsearch.helpers
-from elasticsearch.client import IndicesClient
-import sys, os
-
-def readFileToJson(fileName):
- print "read file ", fileName
- fo=open(fileName)
- try:
- json_mapping=json.load(fo)
- fo.close()
- except ValueError:
- print "error in reading file " , fileName
- fo.close()
- raise
- return json_mapping
diff --git a/asdctool/src/main/resources/es-resources/index_ops.py b/asdctool/src/main/resources/es-resources/index_ops.py
deleted file mode 100644
index d1f3bb0021..0000000000
--- a/asdctool/src/main/resources/es-resources/index_ops.py
+++ /dev/null
@@ -1,151 +0,0 @@
-import itertools
-import string
-import json
-from datetime import datetime
-from elasticsearch import Elasticsearch
-import elasticsearch
-import elasticsearch.helpers
-from elasticsearch.client import IndicesClient, CatClient
-import sys, os, getopt
-from file_utils import readFileToJson
-from config_properties import getGlobalVar
-
-
-
-def createIndex(client, indexName, createBody):
- try:
- print "start createIndex"
- if (client == None):
- client = Elasticsearch(['localhost'])
- esIndexClient = IndicesClient(client)
- res = deleteIndex(client, indexName)
- if (res != 0):
- print "operation failed"
- return 2
- create_res=elasticsearch.client.IndicesClient.create(esIndexClient, index=indexName, body=createBody)
- print "create index response: ", create_res
- if (create_res['acknowledged'] != True):
- print "failed to create index"
- return 1
- else:
- print "index ",indexName, " created successfully"
- return 0
- except Exception, error:
- print "An exception was thrown!"
- print str(error)
- return 2
-
-
-def deleteIndex(client, indexName):
- try:
- print "start deleteIndex"
- if (client == None):
- client = Elasticsearch(['localhost'])
- esIndexClient = IndicesClient(client)
- isExists=elasticsearch.client.IndicesClient.exists(esIndexClient, indexName)
- if ( isExists == True ):
- delete_res=elasticsearch.client.IndicesClient.delete(esIndexClient, index=indexName)
- if (delete_res['acknowledged'] != True):
- print "failed to delete index"
- return 1
- else:
- print "index ",indexName, " deleted"
- return 0
- else:
- print "index not found - assume already deleted"
- return 0
- except Exception, error:
- print "An exception was thrown!"
- print str(error)
- return 2
-
-def copyIndex(client, fromIndex, toIndex):
- try:
- print "start copyIndex"
- if (client == None):
- client = Elasticsearch(['localhost'])
- client.indices.refresh(index=fromIndex)
- count=client.search(fromIndex, search_type='count')
- print "original index count: ",count
- docNum, docErrors = elasticsearch.helpers.reindex(client, fromIndex, toIndex)
- print "copy result: ", docNum, docErrors
- if (docNum != count['hits']['total']):
- print "Failed to copy all documents. expected: ", count['hits']['total'], " actual: ", docNum
- return 1
- # if (len(docErrors) != 0):
- # print "copy returned with errors"
- # print docErrors
- # return 1
- return 0
- except Exception, error:
- print "An exception was thrown!"
- print str(error)
- return 2
-
-
-def usage():
- print 'USAGE: ', sys.argv[0], '-o <operation : create | delete | move> -n <indexName> -a <address> -f <mappingFile (for create)> -t <toIndex (for move operation)>'
-
-
-
-def main(argv):
- print "start script with ", len(sys.argv), 'arguments.'
- print "=============================================="
-
- try:
- opts, args = getopt.getopt(argv, "h:o:a:n:f:t:", ["operation","address","indexName","file","toIndex"])
- except getopt.GetoptError:
- usage()
- sys.exit(2)
-
- host = None
- for opt, arg in opts:
- print opt, arg
- if opt == '-h':
- usage()
- sys.exit(2)
- elif opt in ('-f', '--file'):
- mapping=readFileToJson(arg)
- elif opt in ('-a', '--address'):
- host=arg
- elif opt in ('-o', '--operation'):
- operation=arg
- elif opt in ('-n', '--indexName'):
- indexName=arg
- elif opt in ('-t', '--toIndex'):
- destIndexName=arg
-
- if (operation == None):
- usage()
- sys.exit(2)
- elif (host == None):
- print "address is mandatory argument"
- usage()
- sys.exit(2)
- elif operation == 'create':
- print "create new index ", indexName
- client = Elasticsearch([{'host': host, 'timeout':5}] )
- res = createIndex(client, indexName, mapping)
-
- elif operation == 'delete':
- print "delete index ", indexName
- client = Elasticsearch([{'host': host, 'timeout':5}] )
- res = deleteIndex(client, indexName)
-
- elif operation == 'move':
- print "move index ", indexName, " to ", destIndexName
- client = Elasticsearch([{'host': host, 'timeout':5}] )
- res = copyIndex(client, indexName, destIndexName)
- else:
- usage()
- exit(2)
- if res != 0:
- print "ERROR: operation Failed"
- exit(1)
-
-
-
-if __name__ == "__main__":
- main(sys.argv[1:])
-
-
diff --git a/asdctool/src/main/resources/es-resources/types/auditinggetuebclusterevent.txt b/asdctool/src/main/resources/es-resources/types/auditinggetuebclusterevent.txt
deleted file mode 100644
index b7e9435f97..0000000000
--- a/asdctool/src/main/resources/es-resources/types/auditinggetuebclusterevent.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-{ "action": "ACTION",
- "timestamp": "TIMESTAMP",
- "requestId": "REQUEST_ID",
- "serviceInstanceId": "SERVICE_INSTANCE_ID",
- "desc": "DESC",
- "status": "STATUS",
- "consumerId": "CONSUMER_ID"
-} \ No newline at end of file
diff --git a/asdctool/src/main/resources/es-resources/types/distributiondeployevent.txt b/asdctool/src/main/resources/es-resources/types/distributiondeployevent.txt
deleted file mode 100644
index a74f0370e6..0000000000
--- a/asdctool/src/main/resources/es-resources/types/distributiondeployevent.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "action": "ACTION",
- "timestamp": "TIMESTAMP",
- "requestId": "REQUEST_ID",
- "serviceInstanceId": "SERVICE_INSTANCE_ID",
- "desc": "DESC",
- "status": "STATUS",
- "currVersion": "CURR_VERSION",
- "distributionId": "DID",
- "modifierName": "MODIFIER_NAME",
- "modifierUid": "MODIFIER_UID",
- "resourceName": "RESOURCE_NAME",
- "resourceType": "RESOURCE_TYPE"
-} \ No newline at end of file
diff --git a/asdctool/src/main/resources/es-resources/types/distributiondownloadevent.txt b/asdctool/src/main/resources/es-resources/types/distributiondownloadevent.txt
deleted file mode 100644
index 879c4c4231..0000000000
--- a/asdctool/src/main/resources/es-resources/types/distributiondownloadevent.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-{ "action": "ACTION",
- "timestamp": "TIMESTAMP",
- "requestId": "REQUEST_ID",
- "serviceInstanceId": "SERVICE_INSTANCE_ID",
- "desc": "DESC",
- "status": "STATUS",
- "resourceUrl": "RESOURCE_URL",
- "consumerId": "CONSUMER_ID"
-} \ No newline at end of file
diff --git a/asdctool/src/main/resources/es-resources/types/distributionengineevent.txt b/asdctool/src/main/resources/es-resources/types/distributionengineevent.txt
deleted file mode 100644
index a261042720..0000000000
--- a/asdctool/src/main/resources/es-resources/types/distributionengineevent.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "action": "ACTION",
- "timestamp": "TIMESTAMP",
- "requestId": "REQUEST_ID",
- "serviceInstanceId": "SERVICE_INSTANCE_ID",
- "desc": "DESC",
- "status": "STATUS",
- "consumerId": "CONSUMER_ID",
- "role": "ROLE",
- "topicName": "TOPIC_NAME",
- "apiKey": "API_KEY",
- "environmentName": "D_ENV"
-} \ No newline at end of file
diff --git a/asdctool/src/main/resources/es-resources/types/distributionnotificationevent.txt b/asdctool/src/main/resources/es-resources/types/distributionnotificationevent.txt
deleted file mode 100644
index 6375ead9bb..0000000000
--- a/asdctool/src/main/resources/es-resources/types/distributionnotificationevent.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "action": "ACTION",
- "timestamp": "TIMESTAMP",
- "requestId": "REQUEST_ID",
- "serviceInstanceId": "SERVICE_INSTANCE_ID",
- "desc": "DESC",
- "status": "STATUS",
- "currVersion": "CURR_VERSION",
- "currState": "CURR_STATE",
- "distributionId": "DID",
- "modifierName": "MODIFIER_NAME",
- "modifierUid": "MODIFIER_UID",
- "resourceName": "RESOURCE_NAME",
- "resourceType": "RESOURCE_TYPE",
- "topicName": "TOPIC_NAME"
-} \ No newline at end of file
diff --git a/asdctool/src/main/resources/es-resources/types/distributionstatusevent.txt b/asdctool/src/main/resources/es-resources/types/distributionstatusevent.txt
deleted file mode 100644
index 8fed9dd0c0..0000000000
--- a/asdctool/src/main/resources/es-resources/types/distributionstatusevent.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "action": "ACTION",
- "timestamp": "TIMESTAMP",
- "requestId": "REQUEST_ID",
- "serviceInstanceId": "SERVICE_INSTANCE_ID",
- "desc": "DESC",
- "status": "STATUS",
- "resourceUrl": "RESOURCE_URL",
- "consumerId": "CONSUMER_ID",
- "distributionId": "DID",
- "topicName": "TOPIC_NAME"
-} \ No newline at end of file
diff --git a/asdctool/src/main/resources/es-resources/types/resourceadminevent.txt b/asdctool/src/main/resources/es-resources/types/resourceadminevent.txt
deleted file mode 100644
index 4631aa3367..0000000000
--- a/asdctool/src/main/resources/es-resources/types/resourceadminevent.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "action": "ACTION",
- "timestamp": "TIMESTAMP",
- "requestId": "REQUEST_ID",
- "serviceInstanceId": "SERVICE_INSTANCE_ID",
- "desc": "DESC",
- "status": "STATUS",
- "currVersion": "CURR_VERSION",
- "currState": "CURR_STATE",
- "distributionId": "DID",
- "modifierName": "MODIFIER_NAME",
- "modifierUid": "MODIFIER_UID",
- "prevVersion": "PREV_VERSION",
- "prevState": "PREV_STATE",
- "resourceName": "RESOURCE_NAME",
- "resourceType": "RESOURCE_TYPE",
- "dPrevStatus": "DPREV_STATUS",
- "dCurrStatus": "DCURR_STATUS",
- "comment": "COMMENT",
- "artifactName": "ARTIFACT_NAME"
-} \ No newline at end of file
diff --git a/asdctool/src/main/resources/es-resources/types/useraccessevent.txt b/asdctool/src/main/resources/es-resources/types/useraccessevent.txt
deleted file mode 100644
index ebd27b55e3..0000000000
--- a/asdctool/src/main/resources/es-resources/types/useraccessevent.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "action": "ACTION",
- "timestamp": "TIMESTAMP",
- "requestId": "REQUEST_ID",
- "serviceInstanceId": "SERVICE_INSTANCE_ID",
- "desc": "DESC",
- "status": "STATUS",
- "userUid": "USER_UID",
- "userName": "USER_NAME"
-} \ No newline at end of file
diff --git a/asdctool/src/main/resources/es-resources/types/useradminevent.txt b/asdctool/src/main/resources/es-resources/types/useradminevent.txt
deleted file mode 100644
index 15e0d9bdca..0000000000
--- a/asdctool/src/main/resources/es-resources/types/useradminevent.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "action": "ACTION",
- "timestamp": "TIMESTAMP",
- "requestId": "REQUEST_ID",
- "serviceInstanceId": "SERVICE_INSTANCE_ID",
- "desc": "DESC",
- "status": "STATUS",
- "modifierName": "MODIFIER_NAME",
- "modifierUid": "MODIFIER_UID",
- "userUid": "USER_UID",
- "userName": "USER_NAME",
- "userEmail": "USER_EMAIL",
- "userRole": "USER_ROLE",
- "userBeforeName": "USER_BEFORE_NAME",
- "userBeforeEmail": "USER_BEFORE_EMAIL",
- "userBeforeRole": "USER_BEFORE_ROLE",
- "userAfterName": "USER_AFTER_NAME",
- "userAfterEmail": "USER_AFTER_EMAIL",
- "userAfterRole": "USER_AFTER_ROLE"
-} \ No newline at end of file