6
6
import common
7
7
import board_cfg_lib
8
8
9
- SOURCE_ROOT_DIR = common .SOURCE_ROOT_DIR
10
9
HEADER_LICENSE = common .open_license ()
11
- BOARD_INFO_FILE = "board_info.txt"
12
- SCENARIO_INFO_FILE = ""
13
10
14
11
LOAD_ORDER_TYPE = ['PRE_LAUNCHED_VM' , 'SOS_VM' , 'POST_LAUNCHED_VM' ]
15
12
START_HPA_LIST = ['0' , '0x100000000' , '0x120000000' ]
39
36
40
37
ERR_LIST = {}
41
38
42
- VM_COUNT = 0
43
39
DEFAULT_VM_COUNT = {
44
40
'sdc' :2 ,
45
41
'sdc2' :4 ,
49
45
}
50
46
KATA_VM_COUNT = 0
51
47
52
- LEGACY_TTYS = {
53
- 'ttyS0' :'0x3F8' ,
54
- 'ttyS1' :'0x2F8' ,
55
- 'ttyS2' :'0x3E8' ,
56
- 'ttyS3' :'0x2E8' ,
57
- }
58
-
59
- def prepare ():
60
- """ Check environment """
61
- return common .prepare ()
62
-
63
-
64
- def print_yel (msg , warn = False ):
65
- """
66
- Print the message with color of yellow
67
- :param msg: the stings which will be output to STDOUT
68
- :param warn: the condition if needs to be output the color of yellow with 'Warning'
69
- """
70
- common .print_yel (msg , warn )
71
-
72
-
73
- def print_red (msg , err = False ):
74
- """
75
- Print the message with color of red
76
- :param msg: the stings which will be output to STDOUT
77
- :param err: the condition if needs to be output the color of red with 'Error'
78
- """
79
- common .print_red (msg , err )
80
-
81
-
82
- def usage (file_name ):
83
- """ This is usage for how to use this tool """
84
- common .usage (file_name )
85
-
86
-
87
- def get_param (args ):
88
- """
89
- Get the script parameters from command line
90
- :param args: this the command line of string for the script without script name
91
- """
92
- return common .get_param (args )
93
-
94
-
95
- def get_scenario_name ():
96
- """
97
- Get board name from scenario.xml at fist line
98
- :param scenario_file: it is a file what contains scenario information for script to read from
99
- """
100
- return common .get_scenario_name ()
101
-
102
-
103
- def is_config_file_match ():
104
-
105
- return common .is_config_file_match ()
106
-
107
-
108
- def get_info (board_info , msg_s , msg_e ):
109
- """
110
- Get information which specify by argument
111
- :param board_info: it is a file what contains board information for script to read from
112
- :param msg_s: it is a pattern of key stings what start to match from board information
113
- :param msg_e: it is a pattern of key stings what end to match from board information
114
- """
115
- info_lines = board_cfg_lib .get_info (board_info , msg_s , msg_e )
116
- return info_lines
117
-
118
-
119
- def get_processor_info (board_info ):
120
- """
121
- Get cpu core list
122
- :param board_info: it is a file what contains board information for script to read from
123
- :return: cpu processor which one cpu has
124
- """
125
- processor_list = []
126
- tmp_list = []
127
- processor_info = board_cfg_lib .get_info (board_info , "<CPU_PROCESSOR_INFO>" , "</CPU_PROCESSOR_INFO>" )
128
-
129
- if not processor_info :
130
- key = "vm:id=0,vcpu_affinity"
131
- ERR_LIST [key ] = "CPU core is not exists"
132
- return processor_list
133
-
134
- for processor_line in processor_info :
135
- if not processor_line :
136
- break
137
-
138
- processor_list = processor_line .strip ().split (',' )
139
- for processor in processor_list :
140
- tmp_list .append (processor .strip ())
141
- break
142
-
143
- return tmp_list
144
-
145
-
146
- def get_rootdev_info (board_info ):
147
- """
148
- Get root devices from board info
149
- :param board_info: it is a file what contains board information for script to read from
150
- :return: root devices list
151
- """
152
- rootdev_list = []
153
- rootdev_info = board_cfg_lib .get_info (board_info , "<BLOCK_DEVICE_INFO>" , "</BLOCK_DEVICE_INFO>" )
154
-
155
- # none 'BLOCK_DEVICE_INFO' tag
156
- if rootdev_info == None :
157
- return rootdev_list
158
-
159
- for rootdev_line in rootdev_info :
160
- if not rootdev_line :
161
- break
162
-
163
- if not board_cfg_lib .handle_root_dev (rootdev_line ):
164
- continue
165
-
166
- root_dev = rootdev_line .strip ().split (':' )[0 ]
167
- rootdev_list .append (root_dev )
168
-
169
- return rootdev_list
170
-
171
-
172
- def get_ttys_info (board_info ):
173
- """
174
- Get ttySn from board info
175
- :param board_info: it is a file what contains board information for script to read from
176
- :return: serial console list
177
- """
178
- ttys_list = []
179
- ttys_info = board_cfg_lib .get_info (board_info , "<TTYS_INFO>" , "</TTYS_INFO>" )
180
-
181
- for ttys_line in ttys_info :
182
- if not ttys_line :
183
- break
184
-
185
- ttys_dev = ttys_line .split ()[0 ].split (':' )[1 ]
186
- ttysn = ttys_dev .split ('/' )[- 1 ]
187
- # currently SOS console can only support legacy serial port
188
- if ttysn not in list (LEGACY_TTYS .keys ()):
189
- continue
190
- ttys_list .append (ttys_dev )
191
-
192
- return ttys_list
193
-
194
48
195
49
def get_board_private_info (config_file ):
196
50
197
- (err_dic , scenario_name ) = get_scenario_name ()
51
+ (err_dic , scenario_name ) = common . get_scenario_name ()
198
52
199
53
if scenario_name == "logical_partition" :
200
54
branch_tag = "os_config"
@@ -204,7 +58,7 @@ def get_board_private_info(config_file):
204
58
private_info = {}
205
59
dev_private_tags = ['rootfs' , 'console' ]
206
60
for tag_str in dev_private_tags :
207
- dev_setting = get_sub_leaf_tag (config_file , branch_tag , tag_str )
61
+ dev_setting = common . get_sub_leaf_tag (config_file , branch_tag , tag_str )
208
62
if not dev_setting and tag_str == "console" :
209
63
continue
210
64
@@ -215,41 +69,21 @@ def get_board_private_info(config_file):
215
69
216
70
def check_board_private_info ():
217
71
218
- (err_dic , private_info ) = get_board_private_info (SCENARIO_INFO_FILE )
72
+ (err_dic , private_info ) = get_board_private_info (common . SCENARIO_INFO_FILE )
219
73
220
74
if not private_info ['rootfs' ] and err_dic :
221
75
ERR_LIST ['vm:id=0,boot_private,rootfs' ] = "The board have to chose one rootfs partition"
222
76
ERR_LIST .update (err_dic )
223
77
224
78
225
- def get_vm_num (config_file ):
226
- """
227
- This is get vm count
228
- :param config_file: it is a file what contains vm information for script to read from
229
- :return: number of vm
230
- """
231
- return common .get_vm_num (config_file )
232
-
233
-
234
- def get_sub_leaf_tag (config_file , branch_tag , tag_str = '' ):
235
- """
236
- This is get tag value by tag_str from config file
237
- :param config_file: it is a file what contains information for script to read from
238
- :param branch_tag: it is key of patter to config file branch tag item
239
- :param tag_str: it is key of pattern to config file leaf tag item
240
- :return: value of tag_str item
241
- """
242
- return common .get_sub_leaf_tag (config_file , branch_tag , tag_str )
243
-
244
-
245
79
def get_order_type_by_vmid (idx ):
246
80
"""
247
81
Get load order by vm id
248
82
249
83
:param idx: index of vm id
250
84
:return: load order type of index to vmid
251
85
"""
252
- (err_dic , order_type ) = common .get_load_order_by_vmid (SCENARIO_INFO_FILE , VM_COUNT , idx )
86
+ (err_dic , order_type ) = common .get_load_order_by_vmid (common . SCENARIO_INFO_FILE , common . VM_COUNT , idx )
253
87
if err_dic :
254
88
ERR_LIST .update (err_dic )
255
89
@@ -375,17 +209,6 @@ def uuid_format_check(uuid_dic, item):
375
209
ERR_LIST [key ] = "VM uuid format unknown"
376
210
377
211
378
- def get_leaf_tag_map (info_file , prime_item , item = '' ):
379
- """
380
- :param info_file: some configurations in the info file
381
- :param prime_item: the prime item in xml file
382
- :param item: the item in xml file
383
- :return: dictionary which item value could be indexed by vmid
384
- """
385
- vmid_item_dic = common .get_leaf_tag_map (info_file , prime_item , item )
386
- return vmid_item_dic
387
-
388
-
389
212
def cpus_per_vm_check (id_cpus_per_vm_dic , item ):
390
213
"""
391
214
Check cpu number of per vm
@@ -618,7 +441,7 @@ def get_vuart1_vmid(vm_vuart1):
618
441
:return: dictionary of vmid:vuart1
619
442
"""
620
443
vm_id_dic = {}
621
- for i in range (VM_COUNT ):
444
+ for i in range (common . VM_COUNT ):
622
445
for key in vm_vuart1 [i ].keys ():
623
446
if key == "target_vm_id" :
624
447
vm_id_dic [i ] = vm_vuart1 [i ][key ]
@@ -685,21 +508,10 @@ def clos_assignment(clos_per_vm, index):
685
508
vm_clos_bmp ['clos_map' ] = clos_str
686
509
return vm_clos_bmp
687
510
688
- def get_vuart_info_id (config_file , idx ):
689
- """
690
- Get vuart information by vuart id indexx
691
- :param config_file: it is a file what contains information for script to read from
692
- :param idx: vuart index in range: [0,1]
693
- :return: dictionary which stored the vuart-id
694
- """
695
- tmp_tag = board_cfg_lib .get_vuart_info_id (config_file , idx )
696
- return tmp_tag
697
-
698
511
699
512
def avl_vuart_ui_select (scenario_info ):
700
- vm_num = get_vm_num (scenario_info )
701
513
tmp_vuart = {}
702
- for vm_i in range (vm_num ):
514
+ for vm_i in range (common . VM_COUNT ):
703
515
vm_type = get_order_type_by_vmid (vm_i )
704
516
705
517
if vm_type == "SOS_VM" :
@@ -718,14 +530,9 @@ def avl_vuart_ui_select(scenario_info):
718
530
719
531
def get_first_post_vm ():
720
532
721
- for i in range (VM_COUNT ):
722
- (err_dic , vm_type ) = common .get_load_order_by_vmid (SCENARIO_INFO_FILE , VM_COUNT , i )
533
+ for i in range (common . VM_COUNT ):
534
+ (err_dic , vm_type ) = common .get_load_order_by_vmid (common . SCENARIO_INFO_FILE , common . VM_COUNT , i )
723
535
if vm_type == "POST_LAUNCHED_VM" :
724
536
break
725
537
726
538
return (err_dic , i )
727
-
728
-
729
- def mkdir (path ):
730
-
731
- common .mkdir (path )
0 commit comments