blob: e5dfae57338b22d397ecc99a3fda0fd79b073882 [file] [log] [blame]
Enbo Wang818f76a2020-03-04 00:42:31 +08001#!/usr/bin/python3
2# ============LICENSE_START=======================================================
3# ONAP - SO
4# ================================================================================
5# Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
6# ================================================================================
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18# ============LICENSE_END=========================================================
Enbo Wang6ab8b622019-04-23 13:42:21 +000019
20import sys
21import json
22
23import conf
Enbo Wang818f76a2020-03-04 00:42:31 +080024import upgrade_post_check
Enbo Wang6ab8b622019-04-23 13:42:21 +000025
26
27def main():
Enbo Wang818f76a2020-03-04 00:42:31 +080028 # {{pnfName}} {{oldSwVersion}} {{targetSwVersion}} {{ruleName}} {{additionalDataFile}}
Enbo Wang6ab8b622019-04-23 13:42:21 +000029
30 if len(sys.argv) < 5:
31 ret_value = {
32 "result": conf.RESULT_FAILURE,
33 "reason": "Missing parameters"
34 }
Enbo Wang818f76a2020-03-04 00:42:31 +080035 print(json.dumps(ret_value))
Enbo Wang6ab8b622019-04-23 13:42:21 +000036 sys.exit(conf.RET_CODE_FAILURE)
Enbo Wang818f76a2020-03-04 00:42:31 +080037 else:
38 pnf_name = sys.argv[1]
Enbo Wang6ab8b622019-04-23 13:42:21 +000039 old_sw_version = sys.argv[2]
40 target_sw_version = sys.argv[3]
41 rule_name = sys.argv[4]
Enbo Wang818f76a2020-03-04 00:42:31 +080042 additional_data_file = None
Enbo Wang6ab8b622019-04-23 13:42:21 +000043
44 if len(sys.argv) >= 6:
Enbo Wang818f76a2020-03-04 00:42:31 +080045 additional_data_file = sys.argv[5]
Enbo Wang6ab8b622019-04-23 13:42:21 +000046
Enbo Wang818f76a2020-03-04 00:42:31 +080047 ret_value = upgrade_post_check.post_check(
48 pnf_name, old_sw_version, target_sw_version, rule_name, additional_data_file)
49 print(json.dumps(ret_value))
Enbo Wang6ab8b622019-04-23 13:42:21 +000050
51 if ret_value["result"] == conf.RESULT_SUCCESS:
52 sys.exit(conf.RET_CODE_SUCCESS)
53 else:
54 sys.exit(conf.RET_CODE_FAILURE)
55
56
57if __name__ == '__main__':
58 main()