def disks(self, disks, compname, log):
        rm = RelationshipMap()
        rm.compname = compname
        rm.relname = 'disks'
        rm.modname = 'ZenPacks.CS.NetApp.CMode.Disk'
        rm.classname = 'Disk'

        for disk in disks:
            om = ObjectMap()
            om.modname = 'ZenPacks.CS.NetApp.CMode.Disk'
            om.id = self.prepId(disk['disk']['name'])
            om.disk_name = disk['disk']['name']
            om.position = disk['position']
            om.state = disk['state']
            om.type = disk['type']
            om.usable_size = disk['usable_size']
            rm.append(om)

        return rm
    def raidgroups(self, raidgroups, compname, log):
        rm = RelationshipMap()
        rm.compname = compname
        rm.relname = 'raidGroups'
        rm.modname = 'ZenPacks.CS.NetApp.CMode.RaidGroup'
        rm.classname = 'RaidGroup'

        for raid in raidgroups:
            om = ObjectMap()
            om.modname = 'ZenPacks.CS.NetApp.CMode.RaidGroup'
            om.id = self.prepId(raid['name'])
            om.rg_name = raid['name']
            om.cache_tier = raid['cache_tier']
            om.degraded = raid['degraded']
            om.recomputing_parity_active = raid['recomputing_parity']['active']
            om.reconstruct_active = raid['reconstruct']['active']
            rm.append(om)

            compname = '{parent}/raidGroups/{id}'.format(parent=compname,
                                                         id=om.id)
            diskrm = self.disks(raid['disks'], compname, log)

        return (rm, diskrm)
    def plexes(self, device, uuid, baseUrl, auth, compname, log):
        try:
            response = yield getPage(
                '{url}/storage/aggregates/{oid}/plexes?fields=online,state,pool,resync,raid_groups&return_records=true&return_timeout=15'
                .format(url=baseUrl, oid=uuid),
                headers=auth)
            response = json.loads(response)
        except Exception, e:
            log.error('%s: %s', device.id, e)
            returnValue(None)

        rm = RelationshipMap()
        rm.compname = compname
        rm.relname = 'plexs'
        rm.modname = 'ZenPacks.CS.NetApp.CMode.Plex'
        rm.classname = 'Plex'

        for record in response['records']:
            om = ObjectMap()
            om.modname = 'ZenPacks.CS.NetApp.CMode.Plex'
            om.id = self.prepId(record['name'])
            om.plex_name = record['name']
            om.online = record['online']
            om.plex_state = record['state']
            om.pool = record['pool']
            om.resync = record['resync']['active']
            rm.append(om)

            compname = '{parent}/plexs/{id}'.format(parent=compname, id=om.id)
            raidgrouprm, diskrm = self.raidgroups(record['raid_groups'],
                                                  compname, log)
        return results

    @inlineCallbacks
    def spares(self, device, uuid, baseUrl, auth, compname, log):
        try:
            response = yield getPage('{url}/storage/disks?state=spare&fields=name,uid,serial_number,model,vendor,firmware_version,usable_size,rpm,type,class,pool,bay,node&return_records=true&return_timeout=15'.format(url=baseUrl), headers=auth)
            response = json.loads(response)
        except Exception, e:
            log.error('%s: %s', device.id, e)
            returnValue(None)

        rm = RelationshipMap()
        rm.compname = compname
        rm.relname = 'spareDisks'
        rm.modname = 'ZenPacks.CS.NetApp.CMode.SpareDisk'
        rm.classname = 'SpareDisk'

        for record in response['records']:
            if uuid != record['node']['uuid']: continue
            om = ObjectMap()
            om.modname = 'ZenPacks.CS.NetApp.CMode.SpareDisk'
            om.id = self.prepId(record['name'])
            om.sparedisk_name = record['name']
            om.disk_uid = record['uid']
            om.serialnr = record['serial_number']
            om.model = record['model']
            om.vendor = record['vendor']
            om.firmware = record['firmware_version']
            om.usable_size = record['usable_size']
            om.rpm = record['rpm']
            om.type = record['type']