Example #1
0
    def _get_iscsi_conf(self, filename):
        """Get iSCSI info from config file.

        This function returns a dict:
        {'DefaultTargetIP': '11.11.11.11',
         'Initiator': [{'Name': 'iqn.xxxxxx.1', 'TargetIP': '11.11.11.12'},
                       {'Name': 'iqn.xxxxxx.2', 'TargetIP': '11.11.11.13'}
                      ]
        }

        """

        iscsiinfo = {}
        root = ssh_common.parse_xml_file(filename)

        default_ip = root.findtext('iSCSI/DefaultTargetIP')
        if default_ip:
            iscsiinfo['DefaultTargetIP'] = default_ip.strip()
        else:
            iscsiinfo['DefaultTargetIP'] = None
        initiator_list = []
        tmp_dic = {}
        for dic in root.findall('iSCSI/Initiator'):
            # Strip the values of dict.
            for k, v in dic.items():
                tmp_dic[k] = v.strip()
            initiator_list.append(tmp_dic)
        iscsiinfo['Initiator'] = initiator_list
        return iscsiinfo
Example #2
0
    def _get_iscsi_conf(self, filename):
        """Get iSCSI info from config file.

        This function returns a dict:
        {'DefaultTargetIP': '11.11.11.11',
         'Initiator': [{'Name': 'iqn.xxxxxx.1', 'TargetIP': '11.11.11.12'},
                       {'Name': 'iqn.xxxxxx.2', 'TargetIP': '11.11.11.13'}
                      ]
        }

        """

        iscsiinfo = {}
        root = ssh_common.parse_xml_file(filename)

        default_ip = root.findtext('iSCSI/DefaultTargetIP')
        if default_ip:
            iscsiinfo['DefaultTargetIP'] = default_ip.strip()
        else:
            iscsiinfo['DefaultTargetIP'] = None
        initiator_list = []
        tmp_dic = {}
        for dic in root.findall('iSCSI/Initiator'):
            # Strip the values of dict.
            for k, v in dic.items():
                tmp_dic[k] = v.strip()
            initiator_list.append(tmp_dic)
        iscsiinfo['Initiator'] = initiator_list
        return iscsiinfo
Example #3
0
 def _get_conf_info(self, filename):
     """Get product type and connection protocol from config file."""
     root = ssh_common.parse_xml_file(filename)
     product = root.findtext('Storage/Product').strip()
     protocol = root.findtext('Storage/Protocol').strip()
     if (product in self._product.keys() and
             protocol in self._protocol.keys()):
         return (product, protocol)
     else:
         msg = (_('"Product" or "Protocol" is illegal. "Product" should '
                  'be set to either T, Dorado or HVS. "Protocol" should '
                  'be set to either iSCSI or FC. Product: %(product)s '
                  'Protocol: %(protocol)s')
                % {'product': str(product),
                   'protocol': str(protocol)})
         raise exception.InvalidInput(reason=msg)
Example #4
0
 def _get_conf_info(self, filename):
     """Get product type and connection protocol from config file."""
     root = ssh_common.parse_xml_file(filename)
     product = root.findtext('Storage/Product').strip()
     protocol = root.findtext('Storage/Protocol').strip()
     if (product in self._product.keys()
             and protocol in self._protocol.keys()):
         return (product, protocol)
     else:
         msg = (_('"Product" or "Protocol" is illegal. "Product" should '
                  'be set to either T, Dorado or HVS. "Protocol" should '
                  'be set to either iSCSI or FC. Product: %(product)s '
                  'Protocol: %(protocol)s') % {
                      'product': str(product),
                      'protocol': str(protocol)
                  })
         raise exception.InvalidInput(reason=msg)