Example #1
0
def get_vuart_info_id(config_file, idx):
    """
    Get vuart information by vuart id indexx
    :param config_file: it is a file what contains information for script to read from
    :param idx: vuart index in range: [0,1]
    :return: dictionary which stored the vuart-id
    """
    tmp_tag = []
    vm_id = 0
    root = common.get_config_root(config_file)
    for item in root:
        for sub in item:
            tmp_vuart = {}
            for leaf in sub:
                if sub.tag == "vuart" and int(sub.attrib['id']) == idx:
                    tmp_vuart = get_vuart_id(tmp_vuart, leaf.tag, leaf.text)

            # append vuart for each vm
            if tmp_vuart and sub.tag == "vuart":
                #tmp_vuart[vm_id] = tmp_vuart
                tmp_tag.append(tmp_vuart)

        if item.tag == "vm":
            vm_id += 1

    return tmp_tag
def set_pci_vuarts(launch_item_values, scenario_info):
    try:
        launch_item_values['uos,console_vuart'] = DM_VUART0
        vm_types = common.get_leaf_tag_map(scenario_info, 'vm_type')
        sos_vm_id = 0
        for vm_id, vm_type in vm_types.items():
            if vm_type in ['SOS_VM']:
                sos_vm_id = vm_id
        for vm in common.get_config_root(scenario_info).getchildren():
            if vm.tag == 'vm' and scenario_cfg_lib.VM_DB[vm_types[int(
                    vm.attrib['id'])]]['load_type'] == 'POST_LAUNCHED_VM':
                uos_id = int(vm.attrib['id']) - sos_vm_id
                pci_vuart_key = 'uos:id={},communication_vuarts,communication_vuart'.format(
                    uos_id)
                for elem in vm.getchildren():
                    if elem.tag == 'communication_vuart':
                        for sub_elem in elem.getchildren():
                            if sub_elem.tag == 'base' and sub_elem.text == 'PCI_VUART':
                                if pci_vuart_key not in launch_item_values.keys(
                                ):
                                    launch_item_values[pci_vuart_key] = [
                                        '', elem.attrib['id']
                                    ]
                                else:
                                    launch_item_values[pci_vuart_key].append(
                                        elem.attrib['id'])
    except:
        return
def set_pci_vuarts(launch_item_values, scenario_info):
    try:
        launch_item_values['user_vm,console_vuart'] = DM_VUART0
        load_orders = common.get_leaf_tag_map(scenario_info, 'load_order')
        sos_vm_id = 0
        for vm_id, load_order in load_orders.items():
            if load_order in ['SERVICE_VM']:
                sos_vm_id = vm_id
        for vm in list(common.get_config_root(scenario_info)):
            if vm.tag == 'vm' and load_orders[int(
                    vm.attrib['id'])] == 'POST_LAUNCHED_VM':
                user_vmid = int(vm.attrib['id']) - sos_vm_id
                pci_vuart_key = 'user_vm:id={},communication_vuarts,communication_vuart'.format(
                    user_vmid)
                for elem in list(vm):
                    if elem.tag == 'communication_vuart':
                        for sub_elem in list(elem):
                            if sub_elem.tag == 'base' and sub_elem.text == 'PCI_VUART':
                                if pci_vuart_key not in launch_item_values.keys(
                                ):
                                    launch_item_values[pci_vuart_key] = [
                                        '', elem.attrib['id']
                                    ]
                                else:
                                    launch_item_values[pci_vuart_key].append(
                                        elem.attrib['id'])
    except:
        return
def get_post_num_list():
    """
    Get post vm number list
    :return: total post dic: {launch_id:scenario_id} in launch file
    """
    post_vm_list = []

    # get post vm number
    root = common.get_config_root(common.LAUNCH_INFO_FILE)
    for item in root:
        if item.tag == "uos":
            post_vm_list.append(int(item.attrib['id']))

    return post_vm_list
def launch_vm_cnt(config_file):
    """
    Get post vm number
    :param config_file: it is a file what contains information for script to read from
    :return: total post vm number in launch file
    """
    post_vm_count = 0

    # get post vm number
    root = common.get_config_root(config_file)
    for item in root:
        if item.tag == "uos":
            post_vm_count += 1

    return post_vm_count