Enbo Wang | 818f76a | 2020-03-04 00:42:31 +0800 | [diff] [blame] | 1 | #!/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 Wang | 6ab8b62 | 2019-04-23 13:42:21 +0000 | [diff] [blame] | 19 | |
| 20 | import sys |
| 21 | import json |
| 22 | |
| 23 | import conf |
Enbo Wang | 818f76a | 2020-03-04 00:42:31 +0800 | [diff] [blame] | 24 | import upgrade_post_check |
Enbo Wang | 6ab8b62 | 2019-04-23 13:42:21 +0000 | [diff] [blame] | 25 | |
| 26 | |
| 27 | def main(): |
Enbo Wang | 818f76a | 2020-03-04 00:42:31 +0800 | [diff] [blame] | 28 | # {{pnfName}} {{oldSwVersion}} {{targetSwVersion}} {{ruleName}} {{additionalDataFile}} |
Enbo Wang | 6ab8b62 | 2019-04-23 13:42:21 +0000 | [diff] [blame] | 29 | |
| 30 | if len(sys.argv) < 5: |
| 31 | ret_value = { |
| 32 | "result": conf.RESULT_FAILURE, |
| 33 | "reason": "Missing parameters" |
| 34 | } |
Enbo Wang | 818f76a | 2020-03-04 00:42:31 +0800 | [diff] [blame] | 35 | print(json.dumps(ret_value)) |
Enbo Wang | 6ab8b62 | 2019-04-23 13:42:21 +0000 | [diff] [blame] | 36 | sys.exit(conf.RET_CODE_FAILURE) |
Enbo Wang | 818f76a | 2020-03-04 00:42:31 +0800 | [diff] [blame] | 37 | else: |
| 38 | pnf_name = sys.argv[1] |
Enbo Wang | 6ab8b62 | 2019-04-23 13:42:21 +0000 | [diff] [blame] | 39 | old_sw_version = sys.argv[2] |
| 40 | target_sw_version = sys.argv[3] |
| 41 | rule_name = sys.argv[4] |
Enbo Wang | 818f76a | 2020-03-04 00:42:31 +0800 | [diff] [blame] | 42 | additional_data_file = None |
Enbo Wang | 6ab8b62 | 2019-04-23 13:42:21 +0000 | [diff] [blame] | 43 | |
| 44 | if len(sys.argv) >= 6: |
Enbo Wang | 818f76a | 2020-03-04 00:42:31 +0800 | [diff] [blame] | 45 | additional_data_file = sys.argv[5] |
Enbo Wang | 6ab8b62 | 2019-04-23 13:42:21 +0000 | [diff] [blame] | 46 | |
Enbo Wang | 818f76a | 2020-03-04 00:42:31 +0800 | [diff] [blame] | 47 | 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 Wang | 6ab8b62 | 2019-04-23 13:42:21 +0000 | [diff] [blame] | 50 | |
| 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 | |
| 57 | if __name__ == '__main__': |
| 58 | main() |