blob: 15691070fe9bd95df39926b9bb94e71d91ea458f [file] [log] [blame]
Saqib Khanbb8b63f2017-05-24 10:58:01 -05001#!/usr/bin/env python
2
3r"""
4This module is the python counterpart to code_update.robot.
5"""
6
7import os
8import sys
9import re
10import string
11import tarfile
12import time
13
14robot_pgm_dir_path = os.path.dirname(__file__) + os.sep
15repo_lib_path = re.sub('/extended/code_update/', '/lib', robot_pgm_dir_path)
16repo_data_path = re.sub('/extended/code_update/', '/data', robot_pgm_dir_path)
17sys.path.append(repo_lib_path)
18sys.path.append(repo_data_path)
19
20import gen_robot_keyword as keyword
21import gen_print as gp
22import gen_valid as gv
23import variables as var
24from robot.libraries.BuiltIn import BuiltIn
25
26
27###############################################################################
Charles Paul Hofer2c731642017-08-03 18:13:27 -050028def delete_all_pnor_images():
29
30 r"""
31 Delete all PNOR images from the BMC.
32 """
33
34 status, images = keyword.run_key("Read Properties "
35 + var.SOFTWARE_VERSION_URI + "enumerate")
36 for image_name in images:
37 image_id = image_name.split('/')[-1]
38 image_purpose = images[image_name]["Purpose"]
39 if var.VERSION_PURPOSE_HOST == image_purpose:
40 # Delete twice, in case the image is in the /tmp/images directory
41 keyword.run_key("Call Method " + var.SOFTWARE_VERSION_URI
42 + image_id + " delete data={\"data\":[]}")
43 keyword.run_key("Call Method " + var.SOFTWARE_VERSION_URI
44 + image_id + " delete data={\"data\":[]}")
45
46###############################################################################
47
48
49###############################################################################
Saqib Khanbb8b63f2017-05-24 10:58:01 -050050def wait_for_activation_state_change(version_id, initial_state):
51
52 r"""
53 Wait for the current activation state of ${version_id} to
54 change from the state provided by the calling function.
55
56 Description of argument(s):
57 version_id The version ID whose state change we are waiting for.
58 initial_state The activation state we want to wait for.
59 """
60
61 keyword.run_key_u("Open Connection And Log In")
62 retry = 0
63 while (retry < 20):
64 status, software_state = keyword.run_key("Read Properties " +
George Keishingff1e3ec2017-07-20 01:58:21 -050065 var.SOFTWARE_VERSION_URI + str(version_id))
Saqib Khanbb8b63f2017-05-24 10:58:01 -050066 current_state = (software_state)["Activation"]
67 if (initial_state == current_state):
68 time.sleep(60)
69 retry += 1
70 else:
71 return
72 return
73
74###############################################################################