Example #1
0
def split_status_pools(sp):
    status = []
    pools = []
    first_pool = True
    for line in sp.splitlines():
        if 'pool:' in line:
            if first_pool:
                first_pool = False
            else:
                pools.append('\n'.join(status))
                status = []
        status.append(line)
    pools.append('\n'.join(status))
    return pools
Example #2
0
 def setUp(self):
     with open("fixtures/zpool_status.txt", "r") as f:
         status = []
         self.pools = []
         first_pool = True
         for line in f:
             if 'pool:' in line:
                 if first_pool:
                     first_pool = False
                 else:
                     self.pools.append(''.join(status))
                     status = []
             status.append(line)
         self.pools.append(''.join(status))
Example #3
0
 def setUp(self):
     with open("fixtures/zpool_status.txt", "r") as f:
         status = []
         self.pools = []
         first_pool = True
         for line in f:
             if 'pool:' in line:
                 if first_pool:
                     first_pool = False
                 else:
                     self.pools.append(''.join(status))
                     status = []
             status.append(line)
         self.pools.append(''.join(status))
Example #4
0
    def _parse_xml(self, root):
        elem_tag = self.tags['elem_tag']
        status_tag = self.tags['status_tag']
        elemid = '{}id'.format(self.prefix)
        elemname = '{}name'.format(self.prefix)
        status = []

        for tag in root.findall(self.tags['elemstatus_tag']):
            elem_item = tag.find(elem_tag)
            status_item = tag.find(status_tag)
            item = {
                'id': int(tag.attrib.get('ID', 0)),
                'details': tag.attrib.get('StatusDetails', ''),
                elemid: int(elem_item.attrib.get('ID', 0)),
                elemname: elem_item.attrib.get('Name', ''),
                'statusid': status_item.attrib.get('ID', ''),
                'status': status_item.attrib.get('CssClass', ''),
                'description': status_item.attrib.get('Description', ''),
                'active': stob(status_item.attrib.get('IsActive', ''))
            }
            status.append(item)

        resp = {self.prefix: status}
        return resp
Example #5
0
    def _parse_xml(self, root):
        elem_tag = self.tags["elem_tag"]
        status_tag = self.tags["status_tag"]
        elemid = "{}id".format(self.prefix)
        elemname = "{}name".format(self.prefix)
        status = []

        for tag in root.findall(self.tags["elemstatus_tag"]):
            elem_item = tag.find(elem_tag)
            status_item = tag.find(status_tag)
            item = {
                "id": int(tag.attrib.get("ID", 0)),
                "details": tag.attrib.get("StatusDetails", ""),
                elemid: int(elem_item.attrib.get("ID", 0)),
                elemname: elem_item.attrib.get("Name", ""),
                "statusid": status_item.attrib.get("ID", ""),
                "status": status_item.attrib.get("CssClass", ""),
                "description": status_item.attrib.get("Description", ""),
                "active": stob(status_item.attrib.get("IsActive", "")),
            }
            status.append(item)

        resp = {self.prefix: status}
        return resp