summaryrefslogtreecommitdiffstats
path: root/cvp/update/templates
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2018-07-05 22:37:35 -0400
committerGeorg Kunz <georg.kunz@ericsson.com>2018-07-25 09:17:09 +0000
commit58b91dd3baaaf72ab65062a4804403cd4a5935b2 (patch)
tree801b1f39b3bee25ecbaae387339955d55651e98b /cvp/update/templates
parent947f1bf0147c40971fdae36feecd477ab3caf3b8 (diff)
Move OVP web portal code to a separate repo
The new repo for web portal is https://gerrit.opnfv.org/gerrit/dovetail-webportal JIRA: DOVETAIL-671 Change-Id: Iac085abc3d175b9a091d70d0448af56c7a6845e9 Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'cvp/update/templates')
-rw-r--r--cvp/update/templates/__init__.py0
-rw-r--r--cvp/update/templates/backup_mongodb.py45
-rw-r--r--cvp/update/templates/changes_in_mongodb.py51
-rw-r--r--cvp/update/templates/restore_mongodb.py38
-rwxr-xr-xcvp/update/templates/rm_images.sh8
-rw-r--r--cvp/update/templates/rm_olds.sh15
-rw-r--r--cvp/update/templates/update_mongodb.py90
-rw-r--r--cvp/update/templates/utils.py48
8 files changed, 0 insertions, 295 deletions
diff --git a/cvp/update/templates/__init__.py b/cvp/update/templates/__init__.py
deleted file mode 100644
index e69de29b..00000000
--- a/cvp/update/templates/__init__.py
+++ /dev/null
diff --git a/cvp/update/templates/backup_mongodb.py b/cvp/update/templates/backup_mongodb.py
deleted file mode 100644
index 9c243776..00000000
--- a/cvp/update/templates/backup_mongodb.py
+++ /dev/null
@@ -1,45 +0,0 @@
-##############################################################################
-# Copyright (c) 2016 ZTE Corporation
-# feng.xiaowei@zte.com.cn
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import argparse
-import datetime
-import os
-
-from utils import execute, main, get_abspath
-
-parser = argparse.ArgumentParser(description='Backup MongoDBs')
-
-parser.add_argument('-u', '--url',
- type=str,
- required=False,
- default='mongodb://127.0.0.1:27017/',
- help='Mongo DB URL for Backups')
-parser.add_argument('-o', '--output_dir',
- type=str,
- required=False,
- default='./',
- help='Output directory for the backup.')
-
-parser.add_argument('-d', '--db',
- type=str,
- required=False,
- default='test_results_collection',
- help='database for the backup.')
-
-
-def backup(args):
- db = args.db
- out = get_abspath(args.output_dir)
- now = datetime.datetime.now()
- out = os.path.join(out, '%s__%s' % (db, now.strftime('%Y_%m_%d_%H%M%S')))
- cmd = ['mongodump', '-o', '%s' % out]
- execute(cmd, args)
-
-
-if __name__ == '__main__':
- main(backup, parser)
diff --git a/cvp/update/templates/changes_in_mongodb.py b/cvp/update/templates/changes_in_mongodb.py
deleted file mode 100644
index 1a4d5a16..00000000
--- a/cvp/update/templates/changes_in_mongodb.py
+++ /dev/null
@@ -1,51 +0,0 @@
-##############################################################################
-# Copyright (c) 2016 ZTE Corporation
-# feng.xiaowei@zte.com.cn
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-# 09/06/2016: change for migration after refactoring
-# 16/06/2016: Alignment of test name (JIRA: FUNCTEST-304)
-##############################################################################
-collections_old2New = {
- # 'pod': 'pods',
- # 'test_projects': 'projects',
- # 'test_testcases': 'testcases',
- # 'test_results': 'results'
-}
-
-fields_old2New = {
- # 'test_results': [({}, {'creation_date': 'start_date'})]
-}
-
-docs_old2New = {
- # 'test_results': [
- # ({'criteria': 'failed'}, {'criteria': 'FAILED'}),
- # ({'criteria': 'passed'}, {'criteria': 'PASS'})
- # ]
- # 'testcases': [
- # ({'name': 'vPing'}, {'name': 'vping_ssh'}),
- # ({'name': 'Tempest'}, {'name': 'tempest_smoke_serial'}),
- # ({'name': 'Rally'}, {'name': 'rally_sanity'}),
- # ({'name': 'ODL'}, {'name': 'odl'}),
- # ({'name': 'vIMS'}, {'name': 'vims'}),
- # ({'name': 'ONOS'}, {'name': 'onos'}),
- # ({'name': 'vPing_userdata'}, {'name': 'vping_userdata'}),
- # ({'name': 'ovno'}, {'name': 'ocl'})
- # ],
- # 'results': [
- # ({'case_name': 'vPing'}, {'case_name': 'vping_ssh'}),
- # ({'case_name': 'Tempest'}, {'case_name': 'tempest_smoke_serial'}),
- # ({'case_name': 'Rally'}, {'case_name': 'rally_sanity'}),
- # ({'case_name': 'ODL'}, {'case_name': 'odl'}),
- # ({'case_name': 'vIMS'}, {'case_name': 'vims'}),
- # ({'case_name': 'ONOS'}, {'case_name': 'onos'}),
- # ({'case_name': 'vPing_userdata'}, {'case_name': 'vping_userdata'}),
- # ({'case_name': 'ovno'}, {'case_name': 'ocl'})
- # ]
- 'results': [
- ({'trust_indicator': 0},
- {'trust_indicator': {'current': 0, 'histories': []}})
- ]
-}
diff --git a/cvp/update/templates/restore_mongodb.py b/cvp/update/templates/restore_mongodb.py
deleted file mode 100644
index c45a0e62..00000000
--- a/cvp/update/templates/restore_mongodb.py
+++ /dev/null
@@ -1,38 +0,0 @@
-##############################################################################
-# Copyright (c) 2016 ZTE Corporation
-# feng.xiaowei@zte.com.cn
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import argparse
-
-from utils import execute, main, get_abspath
-
-parser = argparse.ArgumentParser(description='Restore MongoDBs')
-
-parser.add_argument('-u', '--url',
- type=str,
- required=False,
- default='mongodb://127.0.0.1:27017/',
- help='Mongo DB URL for Backup')
-parser.add_argument('-i', '--input_dir',
- type=str,
- required=True,
- help='Input directory for the Restore.')
-parser.add_argument('-d', '--db',
- type=str,
- required=False,
- default='test_results_collection',
- help='database name after the restore.')
-
-
-def restore(args):
- input_dir = get_abspath(args.input_dir)
- cmd = ['mongorestore', '%s' % input_dir]
- execute(cmd, args)
-
-
-if __name__ == '__main__':
- main(restore, parser)
diff --git a/cvp/update/templates/rm_images.sh b/cvp/update/templates/rm_images.sh
deleted file mode 100755
index 6722573b..00000000
--- a/cvp/update/templates/rm_images.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-number=`docker images | awk 'NR != 1' | grep testapi | wc -l`
-if [ $number -gt 0 ]; then
- images=`docker images -a | awk 'NR != 1' | grep testapi | awk '{print $1}'`
- echo "begin to rm images $images"
- docker images | awk 'NR != 1' | grep testapi | awk '{print $3}' | xargs docker rmi -f &>/dev/null
-fi
diff --git a/cvp/update/templates/rm_olds.sh b/cvp/update/templates/rm_olds.sh
deleted file mode 100644
index c6bca186..00000000
--- a/cvp/update/templates/rm_olds.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/bash
-
-proc_number=`ps -ef | grep opnfv-testapi | grep -v grep | wc -l`
-if [ $proc_number -gt 0 ]; then
- procs=`ps -ef | grep opnfv-testapi | grep -v grep`
- echo "begin to kill opnfv-testapi $procs"
- ps -ef | grep opnfv-testapi | grep -v grep | awk '{print $2}' | xargs kill -kill &>/dev/null
-fi
-
-number=`docker ps -a | awk 'NR != 1' | grep testapi | wc -l`
-if [ $number -gt 0 ]; then
- containers=number=`docker ps -a | awk 'NR != 1' | grep testapi`
- echo "begin to rm containers $containers"
- docker ps -a | awk 'NR != 1' | grep testapi | awk '{print $1}' | xargs docker rm -f &>/dev/null
-fi
diff --git a/cvp/update/templates/update_mongodb.py b/cvp/update/templates/update_mongodb.py
deleted file mode 100644
index f7595928..00000000
--- a/cvp/update/templates/update_mongodb.py
+++ /dev/null
@@ -1,90 +0,0 @@
-##############################################################################
-# Copyright (c) 2016 ZTE Corporation
-# feng.xiaowei@zte.com.cn
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import argparse
-
-from pymongo import MongoClient
-
-from changes_in_mongodb import collections_old2New, \
- fields_old2New, docs_old2New
-from utils import main, parse_mongodb_url
-
-parser = argparse.ArgumentParser(description='Update MongoDBs')
-
-parser.add_argument('-u', '--url',
- type=str,
- required=False,
- default='mongodb://127.0.0.1:27017/',
- help='Mongo DB URL for Backups')
-
-parser.add_argument('-d', '--db',
- type=str,
- required=False,
- default='test_results_collection',
- help='database for the update.')
-
-
-def assert_collections(a_dict):
- if a_dict is not None:
- collections = eval_db('collection_names')
- no_collections = []
- for collection in a_dict.keys():
- if collection not in collections:
- no_collections.append(collection)
- assert len(no_collections) == 0, \
- 'collections {} not exist'.format(no_collections)
-
-
-def rename_collections(a_dict):
- if a_dict is not None:
- for collection, new_name in a_dict.iteritems():
- eval_collection(collection, 'rename', new_name)
-
-
-def rename_fields(a_dict):
- collection_update(a_dict, '$rename')
-
-
-def change_docs(a_dict):
- collection_update(a_dict, '$set')
-
-
-def eval_db(method, *args, **kwargs):
- exec_db = db.__getattribute__(method)
- return exec_db(*args, **kwargs)
-
-
-def eval_collection(collection, method, *args, **kwargs):
- exec_collection = db.__getattr__(collection)
- return exec_collection.__getattribute__(method)(*args, **kwargs)
-
-
-def collection_update(a_dict, operator):
- if a_dict is not None:
- for collection, updates in a_dict.iteritems():
- for (query, doc) in updates:
- doc_dict = {operator: doc}
- eval_collection(collection, 'update', query,
- doc_dict, upsert=False, multi=True)
-
-
-def update(args):
- parse_mongodb_url(args.url)
- client = MongoClient(args.url)
- global db
- db = client[args.db]
- assert_collections(docs_old2New)
- assert_collections(fields_old2New)
- assert_collections(collections_old2New)
- change_docs(docs_old2New)
- rename_fields(fields_old2New)
- rename_collections(collections_old2New)
-
-
-if __name__ == '__main__':
- main(update, parser)
diff --git a/cvp/update/templates/utils.py b/cvp/update/templates/utils.py
deleted file mode 100644
index 4254fee3..00000000
--- a/cvp/update/templates/utils.py
+++ /dev/null
@@ -1,48 +0,0 @@
-##############################################################################
-# Copyright (c) 2016 ZTE Corporation
-# feng.xiaowei@zte.com.cn
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import os
-import urlparse
-import subprocess
-
-
-def get_abspath(path):
- assert os.path.isdir(path), 'Path %s can\'t be found.' % path
- return os.path.abspath(path)
-
-
-def parse_mongodb_url(url):
- url = urlparse.urlparse(url)
- assert url.scheme == 'mongodb', 'URL must be a MongoDB URL'
- return url
-
-
-def url_parse(url):
- url = parse_mongodb_url(url)
- return url.username, url.password, url.hostname, url.port
-
-
-def execute(cmd, args):
- (username, password, hostname, port) = url_parse(args.url)
- cmd.extend(['--host', '%s' % hostname, '--port', '%s' % port])
- db = args.db
- if db is not None:
- cmd.extend(['--db', '%s' % db])
- if username is not None:
- cmd.extend(['-u', '%s' % username, '-p', '%s' % password])
- print('execute: %s' % cmd)
- execute_output = subprocess.check_output(cmd)
- print(execute_output)
-
-
-def main(method, parser):
- args = parser.parse_args()
- try:
- method(args)
- except AssertionError as msg:
- print(msg)